/**
 * Created by HIAPAD on 2018/6/22.
 */
/**
 * Created by HIAPAD on 2018/6/22.
 */
// 监听页面滚动
//$(window).on('scroll', function () {
//    // 节流执行 hearder 位置
//    throttle(setHeadBar);
//});
//
//// 头部定位
//function setHeadBar () {
//    var top = $(document).scrollTop();
//
//    if (top > 1) {
//        $(".header").addClass("fixed");
//    }
//    if (!top) {
//        $(".header").removeClass("fixed");
//    }
//}
// 判断图片是否存在
function validateImage(pathImg){
    var ImgObj=new Image();
    ImgObj.src= pathImg;
    if(ImgObj.fileSize > 0 || (ImgObj.width > 0 && ImgObj.height > 0))
    {
        return true;
    } else {
        return false;
    }
}

// $(window).scroll(function(event){
//     var winPos = $(window).scrollTop();
//     console.log("winPos", winPos);
//     if (winPos > 50) {
//         $(".header").addClass("fixed");
//     } else {
//         $(".header").removeClass("fixed");
//     }
// });
//console.log("font-size:", $("html").css("font-size"));
/*
* url 表单提交地址
* formId 表单
* jumpway 点击提示弹框按钮，页面刷新方式
* */
function save (url, formId, cb) {
    saveForm(url, formId, function (res) {
        console.log("res", res);
        if ( typeof res === 'string')   {
            res = JSON.parse(res);
        }
         $.alert(res.info, function () {
             typeof cb === 'function' && cb(res);
         });
    });
}


/*
 * url 表单提交地址
 * formId 表单
 * cb 回调方法
 * */
function saveForm (url, formId, cb) {
    var objForm = '';
    if (formId.indexOf("#") >= 0) {
        objForm = $(formId);
    } else {
        objForm = $("#" + formId);
    }

    if (objForm.length < 0) {
        $.alert("表单不存在！");
        return;
    }
    var data = objForm.serialize();
    console.log("formdata", data);
    if (!data) {
        $.alert(formId + "表单值为空！");
        return;
    }
    $.post(url, data, function (res) {
        typeof cb === 'function' && cb (res);
    });

}

/*
*
* 验证规则
*
* */
var InputStrategy = function () {
  var strategy = {
      // 验证数字
      isNumber: function (value) {
          return /^[0-9]+(\.[0-9]+)?$/.test(value) ? '' : '请输入数字';
      },
      // 验证手机号
      isMobile: function (value) {
          return  /^0?(13[0-9]|15[012356789]|17[0135678]|18[0-9]|14[57])[0-9]{8}$/.test(value) ? '' : '手机号格式不正确';
      },
      // 是否是本地电话
      isPhone: function (value) {
          return /^\d{3}\-\d{8}$|^\d{4}\-\d{7}$/.test(value) ? '' : '请输入正确的电话号码,如010-12345678';
      },
      // 是否是银行卡号
      isBank: function (value) {
          return /^([1-9]{1})(\d{15}|\d{18})$/.test(value) ? '' : '请输入正确的银行卡号';
      },
      // 验证名字
      isUserName: function (value) {
          return /^[\u4e00-\u9fa5]+(·[\u4e00-\u9fa5]+)*$/.test(value) ? '' : '请输入正确名字';

      },
      // 验证身份证号
      isCardNo: function (value) {
          return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(value) ? '' : '请输入正确的身份证号';
      }
  };
    return {
        // 验证 type 算法 value 表单值
        check: function (type, value) {
            // 去除收尾空白
            value = value.replace(/^\s+|\s+$/g, '');
            return strategy[type] ? strategy[type](value) : "没有该检测方法";
        },
        // 添加策略
        addStrategy: function (type, fn) {
            strategy[type] = fn;
        }
    }
}();

/*
*
* 模板创建
*
* */
var A = A || {};

// 创建模板视图合集
A.strategy = {
    // 首页商家列表模板
    'listPart': function (data) {
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;

        //遍历列表数据，并创建模板
        for (var i = 0, len = ldata.length; i < len; i++) {
            htmlText.push('<li class="row"><a href="/mobile/shops/' + ldata[i].id + '">');
            htmlText.push('<div class="img pull-left ">');
            htmlText.push('<img src="' + ldata[i].shop_pic + '" alt="" class="img-responsive" />');
            htmlText.push('</div>');
            htmlText.push('<div class="text pull-left f26">');
            htmlText.push('<div class="title">');
            htmlText.push(ldata[i].shop_name);
            htmlText.push('</div>');
            htmlText.push('<div class="stars">');
            if (ldata[i].score) {
                for (var j = 1; j <= 5; j++) {
                    htmlText.push('<svg class="icon f28" aria-hidden="true">');
                    if (ldata[i].score >= j) {

                        htmlText.push('<use xlink:href="#icon-xingxing0"></use>');

                    } else {
                        htmlText.push('<use xlink:href="#icon-xingxing"></use>');
                    }

                    htmlText.push('</svg>');
                }
            }

            htmlText.push('<span class="ml-10">');
            htmlText.push(ldata[i].score + '.0');
            htmlText.push('</span>');
            htmlText.push('<span>');
            htmlText.push('月售' + ldata[i].sales + '单');
            htmlText.push('</span>');
            htmlText.push('</div>');
            htmlText.push('<div class="info">');
            htmlText.push('<span>');
            htmlText.push('￥ ' + ldata[i].min_spend + '起送');
            htmlText.push('</span>');
            htmlText.push('<span>');
            htmlText.push('配送费 ￥' + ldata[i].spend);
            htmlText.push('</span>');
            htmlText.push('</div>');
            htmlText.push('<div class="btn-way">');
            if (ldata[i].is_takeout) {
                htmlText.push('<span>外卖</span>');
            }
            if (ldata[i].is_reserve) {
                htmlText.push('<span>预定</span>');
            }
            if (ldata[i].is_list) {
                htmlText.push('<span>排队</span>');
            }

            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('</a></li>');

        }

        // 渲染模板数据
        $(A.root).append(htmlText.join(''));
    },
    // 预定列表模板
    'listReserve': function (data) {
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;

        if (ldata.length > 0) {
            //遍历列表数据，并创建模板
            for (var i = 0, len = ldata.length; i < len; i++) {
                htmlText.push('<li class="row"><a href="/mobile/shops/'+ ldata[i].id + '">');
                htmlText.push('<div class="img pull-left">');
                htmlText.push('<img src="' + ldata[i].shop_pic + '" alt="" class="img-responsive" />');
                htmlText.push('</div>');
                htmlText.push('<div class="text pull-left">');
                htmlText.push('<div class="title">');
                htmlText.push(ldata[i].shop_name);
                htmlText.push('</div>');
                htmlText.push('<div class="stars mt-5">');
                if (ldata[i].score) {
                    for (var j = 1; j <= 5; j++) {
                        htmlText.push('<svg class="icon f30" aria-hidden="true">');
                        if (ldata[i].score >= j) {

                            htmlText.push('<use xlink:href="#icon-xingxing0"></use>');

                        } else {
                            htmlText.push('<use xlink:href="#icon-xingxing"></use>');
                        }

                        htmlText.push('</svg>');
                    }
                }

                htmlText.push('<span class="ml-10">');
                htmlText.push(ldata[i].score + '.0');
                htmlText.push('</span>');
                htmlText.push('<span>');
                htmlText.push('月售' + ldata[i].sales + '单');
                htmlText.push('</span>');
                htmlText.push('<span class="pull-right">');
                htmlText.push(getSistanceStr(ldata[i].distance));
                htmlText.push('</span>');
                htmlText.push('</div>');
                htmlText.push('<div class="info mt-5">');
                htmlText.push('<span>');
                htmlText.push('最低消费 ￥' + ldata[i].minimum);
                htmlText.push('</span>');
                // htmlText.push('<span>');
                // htmlText.push('￥ '+ ldata[i].shopinfo.min_spend +'起送');
                // htmlText.push('</span>');
                htmlText.push('</div>');
                htmlText.push('<div class="info mt-5 nowrap">');
                htmlText.push('<span>');
                htmlText.push('营业时间：' + ldata[i].opentime);
                htmlText.push('</span>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</a></li>');

            }
        } else {
            htmlText.push('<p class="text-center pt-10 gary9">没有记录</p>');
        }


        // 渲染模板数据
        $(A.root).append(htmlText.join(''));
    },
    //外卖列表模板
    'listTakeout': function (data) {
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;

        if (ldata.length > 0) {
            //遍历列表数据，并创建模板
            for (var i = 0, len = ldata.length; i < len; i++) {
                htmlText.push('<li class="row"><a href="/mobile/takeout-menu?id='+ ldata[i].id +'&type=takeout">');
                htmlText.push('<div class="img pull-left">');
                htmlText.push('<img src="' + ldata[i].shop_pic + '" alt="" class="img-responsive" />');
                htmlText.push('</div>');
                htmlText.push('<div class="text pull-left">');
                htmlText.push('<div class="title">');
                htmlText.push(ldata[i].shop_name);
                htmlText.push('</div>');
                htmlText.push('<div class="stars mt-5">');
                if (ldata[i].score) {
                    for (var j = 1; j <= 5; j++) {
                        htmlText.push('<svg class="icon f30" aria-hidden="true">');
                        if (ldata[i].score >= j) {

                            htmlText.push('<use xlink:href="#icon-xingxing0"></use>');

                        } else {
                            htmlText.push('<use xlink:href="#icon-xingxing"></use>');
                        }

                        htmlText.push('</svg>');
                    }
                }

                htmlText.push('<span class="ml-10">');
                htmlText.push(ldata[i].score + '.0');
                htmlText.push('</span>');
                htmlText.push('<span>');
                htmlText.push('月售' + ldata[i].sales + '单');
                htmlText.push('</span>');
                htmlText.push('<span class="pull-right">');
                htmlText.push(getSistanceStr(ldata[i].distance));
                htmlText.push('</span>');
                htmlText.push('</div>');
                htmlText.push('<div class="info mt-5">');
                htmlText.push('<span>');
                htmlText.push('最低消费' + ldata[i].minimum);
                htmlText.push('</span>');
                htmlText.push('<span>');
                htmlText.push(ldata[i].min_spend + '起送');
                htmlText.push('</span>');
                htmlText.push('</div>');
                htmlText.push('<div class="btn-way">');
                if (ldata[i].is_pickup == 1) {
                    htmlText.push('<span>支持自取</span>');
                }
                if (ldata[i].is_wifi == 1) {
                    htmlText.push('<span>WIFI</span>');
                }
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</a></li>');

            }

        } else {
            htmlText.push('<p class="text-center pt-10 gary9">没有记录</p>');
        }

        // 渲染模板数据
        $(A.root).append(htmlText.join(''));
    },
    // 排队列表模板
    'listLine': function (data) {
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;

        if (ldata.length > 0) {
            //遍历列表数据，并创建模板
            for (var i = 0, len = ldata.length; i < len; i++) {
                htmlText.push('<li class="row"><a href="/mobile/takeout-line?id='+ ldata[i].id +'&type=line">');
                htmlText.push('<div class="img pull-left">');
                htmlText.push('<img src="' + ldata[i].shop_pic + '" alt="" class="img-responsive" />');
                htmlText.push('</div>');
                htmlText.push('<div class="text pull-left">');
                htmlText.push('<div class="title">');
                htmlText.push(ldata[i].shop_name);
                htmlText.push('</div>');
                htmlText.push('<div class="stars mt-5">');
                if (ldata[i].score) {
                    for (var j = 1; j <= 5; j++) {
                        htmlText.push('<svg class="icon f30" aria-hidden="true">');
                        if (ldata[i].score >= j) {

                            htmlText.push('<use xlink:href="#icon-xingxing0"></use>');

                        } else {
                            htmlText.push('<use xlink:href="#icon-xingxing"></use>');
                        }

                        htmlText.push('</svg>');
                    }
                }

                htmlText.push('<span class="ml-10">');
                htmlText.push(ldata[i].score + '.0');
                htmlText.push('</span>');
                htmlText.push('<span>');
                htmlText.push('月售' + ldata[i].sales + '单');
                htmlText.push('</span>');
                htmlText.push('<span class="pull-right">');
                htmlText.push(getSistanceStr(ldata[i].distance));
                htmlText.push('</span>');
                htmlText.push('</div>');
                htmlText.push('<div class="info mt-5">');
                htmlText.push('<span>');
                htmlText.push('最低消费' + ldata[i].minimum);
                htmlText.push('</span>');
                htmlText.push('<span>');
                htmlText.push('起送' + ldata[i].min_spend);
                htmlText.push('</span>');
                htmlText.push('</div>');
                // htmlText.push('<div class="btn-way">');
                // if (ldata[i].shopinfo.is_pickup == 1) {
                //     htmlText.push('<span>支持自取</span>');
                // }
                // if (ldata[i].shopinfo.is_wifi == 1) {
                //     htmlText.push('<span>WIFI</span>');
                // }
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</a></li>');

            }
        } else {
            htmlText.push('<p class="text-center pt-10 gary9">没有记录</p>');
        }


        // 渲染模板数据
        $(A.root).append(htmlText.join(''));
    },
    // 菜单分类列表
    'shopsMenu': function (data) {
        console.log("data1", data);
        var ldata = data.data,
            htmlText = [],
            contentText = [];
        A.root = data.element;

        // 遍历列表数据,并创建模板
        for (var i = 0, len = ldata.length; i < len; i++) {
            htmlText.push('<li>');
            if (i < 1) {
                htmlText.push('<a href="javascript:;" data-sid="' + data.id + '" data-cid="' + ldata[i].id + '" class="active">');
            } else {
                htmlText.push('<a href="javascript:;" data-sid="' + data.id + '" data-cid="' + ldata[i].id + '">');
            }

            htmlText.push(ldata[i].menu_name);
            htmlText.push('</a>');
            htmlText.push('</li>');

            if (i < 1) {
                contentText.push('<div class="tab-pane active" data-spend="'+ data.spend+'" data-name="'+ data.name +'" data-id="' + data.id + '"  id="' + ldata[i].id + '">');
            } else {
                contentText.push('<div class="tab-pane" data-name="'+ data.name +'" data-id="' + data.id + '" id="' + ldata[i].id + '">');
            }

            contentText.push('<ul class="food-list list-unstyled">');
            contentText.push('</ul>');
            contentText.push('</div>');


        }

        // 渲染模板数据
        $(A.root + " .food-category").html(htmlText.join(''));
        $(A.root + " .tab-content").html(contentText.join(''));
    },
    // 点菜列表
    'shopsList': function (data) {
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;
        console.log("ldata", data);
        if (ldata.length > 0) {
            // 遍历列表数据,并创建模板
            for (var i = 0, len = ldata.length; i < len; i++) {
                htmlText.push('<li class="row">');
                htmlText.push('<div class="col-5">');
                htmlText.push('<a href="/mobile/shopsDetail?id='+ ldata[i].id + '&sid='+ ldata[i].shop_id +'">');
                if (ldata[i].thumb) {
                    htmlText.push('<img src="' + ldata[i].thumb + '" alt="" class="img-responsive">');
                } else {
                    htmlText.push('<img src="/img/eat.png" alt="" class="img-responsive">');
                }

                htmlText.push('</a>');
                htmlText.push('</div>');
                htmlText.push('<div class="col-7">');
                htmlText.push('<div class="text">');
                htmlText.push('<p class="food-title gary3 mt-10">');
                htmlText.push(ldata[i].dishes_name);
                htmlText.push('</p>');
                htmlText.push('<p class="food-order f24 gary9">');
                htmlText.push('月售 ' + ldata[i].sales + ' 单');
                htmlText.push('</p>');
                htmlText.push('<p class="food-money f24 gary9 mt-5">');

                if (ldata[i].discount < 1) {
                    htmlText.push('<del>');
                    htmlText.push('￥' + ldata[i].price);
                    htmlText.push('</del>');
                    htmlText.push('<span>');
                    htmlText.push('￥' + (ldata[i].price * ldata[i].discount).toFixed(2));
                    htmlText.push('</span>');
                } else {
                    htmlText.push('<span>');
                    htmlText.push('￥' + ldata[i].price);
                    htmlText.push('</span>');
                }

                console.log(ldata[i].attribute);
                htmlText.push('</p>');
                if (!ldata[i].attribute || ldata[i].attribute.length <= 0 ) {
                    htmlText.push('<div class="btn pull-right">');
                    htmlText.push('<div class="weui-count" data-text=\'' + JSON.stringify(ldata[i]) + '\'>');
                    // 如果有加到购物车，需要显示出来
                    if (ldata[i].num) {
                        htmlText.push('<a class="weui-count__btn weui-count__decrease" id="del"></a>');
                        htmlText.push(' <input class="weui-count__number input'+ ldata[i].id +'" name="number" type="number" value="' + ldata[i].num + '" id="num"> ');
                    } else {
                        htmlText.push('<a class="weui-count__btn weui-count__decrease hide" id="del"></a>');
                        htmlText.push(' <input class="weui-count__number hide input'+ ldata[i].id +'" name="number" type="number" value="0" id="num"> ');
                    }

                    htmlText.push('<a class="weui-count__btn weui-count__increase" id="add"></a>');
                    htmlText.push('</div>');
                    htmlText.push('</div>');
                } else {
                    htmlText.push('<div class="btn pull-right">');
                    htmlText.push('<a href="javascript:;" data-text=\'' + JSON.stringify(ldata[i]) + '\' class="more-select">多规格</a>');
                    htmlText.push('</div>');
                }

                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</li>');
            }
        } else {
            // $.alert("没有任何菜");
            htmlText.push("<li class='text-center mt-10'>");
            htmlText.push('<svg class="icon f56 gary9" aria-hidden="true">');
            htmlText.push('<use xlink:href=" #icon-weibiaoti--2"></use>');
            htmlText.push(' </svg>');
            htmlText.push('<p class="text-center f24 gary9">');
            htmlText.push('该菜单空空如也');
            htmlText.push('</p>');
            htmlText.push('</li>');

        }

        // 渲染模板数据
        $('.tab-content ' + A.root).find('.food-list').html(htmlText.join(''));
    },
    // 已点的购物车列表
    'myfoods': function (data) {
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;

        if (ldata.length > 0) {
            var spcePrice = 0;
            // 遍历列表数据,并创建模板
            for (var i = 0, len = ldata.length; i < len; i++) {
                htmlText.push('<div class="weui-cell">');
                htmlText.push('<div class="weui-cell__hd">');
                if (ldata[i].thumb) {
                    htmlText.push('<img src="'+ ldata[i].thumb +'" class="img-responsive" style="max-width: .75rem; max-height: .60rem;">');
                } else {
                    htmlText.push('<img src="/img/eat.png" class="img-responsive" style="max-width: .75rem; max-height: .60rem;">');
                }

                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__bd">');
                htmlText.push('<p class="f28">');
                htmlText.push( ldata[i].dishes_name + 'x' + ldata[i].num);
                htmlText.push('</p>');
                if (ldata[i].spec) {
                    htmlText.push('<span class="f28 gary9">');
                    htmlText.push('规格：' + ldata[i].spec);
                    htmlText.push('</span>');
                    // 对多规格菜进行拆分，
                    spcePrice = getMoreFoodPrice(ldata[i].spec);
                } else {
                    // 如果不是多规格，直接设为0
                    spcePrice = 0;
                }

                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__bd">');
                htmlText.push('<p class="f28">');
                htmlText.push('￥'+ parseFloat(ldata[i].discount) * parseInt(ldata[i].num) * (parseFloat(ldata[i].price) + parseFloat(spcePrice)));
                htmlText.push('</p>');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__ft">');

                htmlText.push('<div class="weui-count" data-text=\''+ JSON.stringify(ldata[i]) + '\'>');
                htmlText.push('<a class="weui-count__btn weui-count__decrease" id="del"></a>');
                htmlText.push(' <input class="weui-count__number" name="number" type="number" value="'+ ldata[i].num +'" id="num"> ');
                htmlText.push('<a class="weui-count__btn weui-count__increase" id="add"></a>');
                htmlText.push(' </div>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            }

            // 渲染模板数据
            $(A.root).html(htmlText.join(''));
        }
    },
    //添加地址,渲染模板
    'addressList': function (data){
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;

        if (ldata.length > 0) {
            // 遍历列表数据,并创建模板
            for (var i = 0, len = ldata.length; i < len; i++) {
                htmlText.push('<div class="site weui-cells_checkbox">');
                htmlText.push('<label class="weui-cell  Default">');
                htmlText.push('<input type="radio" class="weui-check" data-text=\''+ JSON.stringify(ldata[i]) +'\' name="myAddress">');
                htmlText.push('<i class="weui-icon-checked shade"  style="display: none;">');
                htmlText.push('</i>');
                htmlText.push('<div class="weui-cell__bd">');
                //{{--姓名-电话渲染-name-}}
                htmlText.push('<div class="weui-cell   ">');
                htmlText.push('<div class="weui-cell__hd">');
                htmlText.push(ldata[i].name);
                htmlText.push('<label for="" class="weui-label">');
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__bd">');
                htmlText.push(ldata[i].mobile);
                htmlText.push('</div>');
                htmlText.push('</div>');
                //{{--所在地区渲染--}}
                htmlText.push('<div class="weui-cell   ">');
                htmlText.push('<div class="weui-cell__hd">');
                htmlText.push(ldata[i].address);
                htmlText.push('</div>');
                htmlText.push('</div>');
                // {{--详细地址渲染--}}
                htmlText.push('<div class="weui-cell street">');
                htmlText.push('<div class="weui-cell__hd">');
                htmlText.push(ldata[i].address_detail);
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</label>');
                htmlText.push('<div class="weui-cell list">');
                htmlText.push('<div class="Device">');
                if (ldata[i].pretermission) {
                    htmlText.push('<input id="weuiAgree" checked data-id="'+ ldata[i].id + '" type="checkbox" class="weui-agree__checkbox setting" onchange="setDefaultAddress(this)">');
                } else {
                    htmlText.push('<input id="weuiAgree" data-id="'+ ldata[i].id + '" type="checkbox" class="weui-agree__checkbox setting" onchange="setDefaultAddress(this)">');
                }

                htmlText.push(' 设置为默认地址');
                htmlText.push('</div>');
                htmlText.push('<a href="/mobile/append?id='+ ldata[i].id + '" class="added weui-btn_mini weui-btn_default">');
                htmlText.push('编辑');
                htmlText.push('</a>');
                htmlText.push('<a href="javascript:;" data-id="'+ ldata[i].id + '" class="added weui-btn_mini weui-btn_default" onclick="delAddress(this)">');
                htmlText.push('删除');
                htmlText.push('</a>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            }
            // 渲染模板数据
            $(A.root).html(htmlText.join(''));
        }
    },
    // 包间列表
    'roomsList': function (data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            htmlText.push('<h3 class="f30">');
            htmlText.push(ldata[0].note);
            htmlText.push('</h3>');
            htmlText.push('<div class="rooms-content">');
            for (var i = 0; i < len; i++) {
                if (i < 1) {
                    htmlText.push('<div class="btn active f30" data-type="'+ ldata[i].type +'" data-id="' + ldata[i].id + '">');
                } else {
                    htmlText.push('<div class="btn f30" data-type="'+ ldata[i].type +'" data-id="' + ldata[i].id + '">');
                }

                htmlText.push('<p class="f30">');
                htmlText.push(ldata[i].name);
                htmlText.push('</p>');
                htmlText.push('<p class="f20">');
                htmlText.push('('+ ldata[i].hold + '人)');
                htmlText.push('</p>');
                htmlText.push('</div>');
            }
            htmlText.push('</div>');
        }
        console.log("123", htmlText.join(''));
        $(A.root).html(htmlText.join(''));
    },
    // 订单列表
    'orderList': function (data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                htmlText.push('<li class="row">');
                htmlText.push('<div class="col-3">');
                htmlText.push('<div class="img">');
                if (ldata[i].shop_avatar) {
                    htmlText.push('<img src="'+ ldata[i].shop_avatar +'" alt="" class="img-responsive">');
                } else {
                    htmlText.push('<img src="/img/eat.png" alt="" class="img-responsive">');
                }

                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('<div class="col-9">');
                htmlText.push('<div class="text">');
                htmlText.push('<a href="/mobile/order-detail?id='+ ldata[i].id +'&order_type='+ ldata[i].order_type +'">');
                htmlText.push('<h3 class="f32">');
                if (ldata[i].order_type === 0) {
                    htmlText.push('外卖');
                } else if (ldata[i].order_type === 1) {
                    htmlText.push('预定');
                } else if (ldata[i].order_type === 2) {
                    htmlText.push('排队');
                } else if (ldata[i].order_type === 3) {
                    htmlText.push('扫码点餐');
                }
                htmlText.push('<span class="pull-right f26">');
                switch(ldata[i].order_status) {
                    case 0:
                        htmlText.push('刚创建');
                        break;
                    case 1:
                        htmlText.push('待支付');
                        break;
                    case 2:
                        htmlText.push('支付成功');
                        break;
                    case 3:
                        htmlText.push('进行中');
                        break;
                    case 4:
                        htmlText.push('已完成');
                        break;
                    case -1:
                        htmlText.push('退款中');
                        break;
                    case -2:
                        htmlText.push('退款完成');
                        break;
                    case -3:
                        htmlText.push('订单关闭');
                        break;
                }

                htmlText.push('</span>');
                htmlText.push('</h3>');
                htmlText.push('<p class="f26 gary6">下单时间：');
                htmlText.push(ldata[i].created_at);
                htmlText.push('</p>');
                htmlText.push('<p class="f26 gary6">总价：￥ ');
                htmlText.push(ldata[i].order_price);
                htmlText.push('</p>');
                // htmlText.push('<p class="f20 del pull-right">删除 ');
                // htmlText.push('</p>');
                htmlText.push('</a>');
                htmlText.push('</div>');
                htmlText.push('<div class="btn row">');
                htmlText.push('<a href="javascript:;" data-id='+ ldata[i].id +' class="del f24">删除</a>');
                if (ldata[i].order_status == 4) {
                    // htmlText.push('<a href="javascript:;" class="order-btn f24">再来一单</a>');
                    htmlText.push('<a href="/mobile/comments?sid='+ ldata[i].shop_id+'&order_id='+ ldata[i].id + '" class="message-btn f24">评价菜单</a>');
                }

                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</li>');
            }
        }
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    // 订单详情面板
    'orderDetail': function (data) {
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;

        htmlText.push('<div class="order-panel">');
        htmlText.push('<div class="order-header">');
        htmlText.push('<h3 class="shop-name arrow-right">');
        htmlText.push('<svg class="icon f48" aria-hidden="true">');
        htmlText.push('<use xlink:href="#icon-weibiaoti--3"></use>');
        htmlText.push('</svg>');
        htmlText.push('<span class="f30"> ');
        htmlText.push(ldata.shop.shop_name);
        htmlText.push('</span>');
        htmlText.push('</h3>');
        htmlText.push('</div>');
        htmlText.push('<div class="order-header">');
        htmlText.push('<h3 class="shop-name">');
        htmlText.push('<span class="f30">订单号：');
        htmlText.push(ldata.order_number);
        htmlText.push('</span>');
        htmlText.push('</h3>');
        htmlText.push('</div>');
        htmlText.push('<div class="order-header">');
        htmlText.push('<h3 class="shop-name">');
        htmlText.push('<span class="f30">类型: ');
        if (ldata.order_type === 0) {
            htmlText.push('外卖');
        } else if (ldata.order_type === 1) {
            htmlText.push('预定');
        } else if (ldata.order_type === 2) {
            htmlText.push('排队');
        } else if (ldata.order_type === 3) {
            htmlText.push('扫码点餐');
        }

        htmlText.push('</span>');
        htmlText.push('</h3>');
        htmlText.push('</div>');
        htmlText.push('<div class="order-content">');
        if (ldata.order_type !== 2) {
            htmlText.push('<div class="foods">');
            // 桌子、包间
            if (ldata.room_table && ldata.room_table.length > 0) {
                var tdata = ldata.room_table,
                    tlen = tdata.length;
                htmlText.push('<p class="f24 gary9">');
                htmlText.push('桌子：' );
                for (var j = 0; j < tlen; j++) {
                    if (tdata[j].type === 0) {
                        htmlText.push(tdata[j].name);
                        htmlText.push('、');
                    }

                }
                htmlText.push('</p>');

                htmlText.push('<p class="f24 gary9">');
                htmlText.push('包间：' );
                for (var j = 0; j < tlen; j++) {
                    if (tdata[j].type === 1) {
                        htmlText.push(tdata[j].name);
                        htmlText.push('、');
                    }

                }
                htmlText.push('</p>');

            }

            // 菜单
            if (ldata.order_detail && ldata.order_detail.length > 0) {
                var fdata = ldata.order_detail,
                    len = fdata.length,
                    spcePrice = 0;

                htmlText.push('<p class="f26 gary9">菜单：</p>');
                for (var i = 0; i < len; i++) {
                    htmlText.push('<p class="f26 gary9">');
                    htmlText.push(fdata[i].dishes_name + 'x' + fdata[i].goods_number);

                    // 对多规格菜进行拆分，
                    if (fdata[i].spec) {
                        spcePrice = getMoreFoodPrice(fdata[i].spec);
                        htmlText.push('<span class="ml-10">');
                        htmlText.push(fdata[i].spec);
                        htmlText.push('</span>');
                        htmlText.push('<span class="f26 gary9 pull-right">');
                        htmlText.push('￥' + (parseFloat(fdata[i].price) + spcePrice).toFixed(2));
                        htmlText.push('</span>');
                    } else {
                        // 如果不是多规格，直接设为0
                        spcePrice = 0;
                        htmlText.push('<span class="f26 gary9 pull-right">');
                        htmlText.push('￥' + (fdata[i].price));
                        htmlText.push('</span>');

                    }
                    htmlText.push('</p>');

                }


            }
            htmlText.push('</div>');

            htmlText.push('<div class="foods-info">');
            if (ldata.order_type == 0) {
                htmlText.push('<p class="f26 gary9">');
                htmlText.push('配送费 <span class="f26 gary9 pull-right">');
                htmlText.push('￥' + ldata.shop_info.spend);
                htmlText.push('</span>');
                htmlText.push('</p>');
            }
        }

        htmlText.push('<p class="f26 gary9">');
        htmlText.push('优惠金额 <span class="f26 gary9 pull-right">');
        htmlText.push('￥' + (parseFloat(ldata.order_price) - parseFloat(ldata.order_amount)).toFixed(2));
        htmlText.push('</span>');
        htmlText.push('</p>');
        htmlText.push('<p class="f26 gary9">总计 <span class="f26 gary9 pull-right">');
        htmlText.push('￥' + ldata.order_amount);
        htmlText.push('</span>');
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('<div class="order-panel">');
        htmlText.push('<div class="order-header">');
        htmlText.push('<p class="f24">');
        htmlText.push('备注: ' + (ldata.note || ''));
        htmlText.push('</p>');
        htmlText.push('<p class="f26 mt-10">');
        htmlText.push('下单时间: ');
        htmlText.push(ldata.created_at);
        htmlText.push('</p>');
        if (ldata.order_status > 1) {
            htmlText.push('<p class="f26 mt-10">');
            htmlText.push('支付方式: ' + ldata.pay_way);
            htmlText.push('</p>');
        }

        htmlText.push('<p class="f26 mt-10">');
        // 0外卖,1预定 ,2排队 ,3扫码 ,
        if (ldata.order_type == 0) {
            switch (ldata.order_status) {
                case 0:
                    htmlText.push('状态: 刚创建');
                    break;
                case 1:
                    htmlText.push('状态: 待支付');
                    break;
                case 2:
                    htmlText.push('状态: 待发货');
                    break;
                case 3:
                    htmlText.push('状态: 待收货');
                    break;
                case 4:
                    htmlText.push('状态: 已收货待评价');
                    break;
                case -1:
                    htmlText.push('状态: 发起退单');
                    break;
                case -2:
                    htmlText.push('状态: 退单处理中');
                    break;
                case -3:
                    htmlText.push('状态: 退单完成');
                    break;
            }
        } else if (ldata.order_type == 1) {
            switch (ldata.order_status) {
                case 1:
                    htmlText.push('状态: 待支付');
                    break;
                case 2:
                    htmlText.push('状态: 已交定金');
                    break;
                case 3:
                    htmlText.push('状态: 进行中');
                    break;
                case 4:
                    htmlText.push('状态: 已结账待评价');
                    break;
                case 5:
                    htmlText.push('状态: 已结账已评价');
                    break;
                case -1:
                    htmlText.push('状态: 发起退单');
                    break;
                case -2:
                    htmlText.push('状态: 退单处理中');
                    break;
                case -3:
                    htmlText.push('状态: 退单完成');
                    break;
            }
        } else if (ldata.order_type == 2) {
            switch (ldata.order_status) {
                case 1:
                    htmlText.push('状态: 待支付');
                    break;
                case 2:
                    htmlText.push('状态: 已交定金');
                    break;
                case 3:
                    htmlText.push('状态: 进行中');
                    break;
                case 4:
                    htmlText.push('状态: 已结账待评价');
                    break;
                case 5:
                    htmlText.push('状态: 已结账已评价');
                    break;
                case -1:
                    htmlText.push('状态: 发起退单');
                    break;
                case -2:
                    htmlText.push('状态: 退单处理中');
                    break;
                case -3:
                    htmlText.push('状态: 退单完成');
                    break;
            }
        } else if (ldata.order_type == 3) {
            switch (ldata.order_status) {
                case 1:
                    htmlText.push('状态: 待支付');
                    break;
                case 4:
                    htmlText.push('状态: 已支付待评价');
                    break;
                case 5:
                    htmlText.push('状态: 已支付已评价');
                    break;
                case 6:
                    htmlText.push('状态: 订单关闭');
                    break;
            }
        }


        htmlText.push('</p>');

        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('<div class="btn-group">');
        // 0外卖,1预定 ,2排队 ,3扫码 ,
        if (ldata.order_type == 0) {
            switch (ldata.order_status) {
                case 1:
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="/mobile/payment?id='+ ldata.id +'&money='+ ldata. order_price +'&order_type='+ ldata. order_type +'" class="weui-btn weui-btn_primary f30" style="width: 100%;">去支付</a>');
                    htmlText.push('</div>');
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<button type="button" class="weui-btn weui-btn_white f30 canel-order">取消定单</button>');
                    htmlText.push('</div>');
                    break;
                case 3:
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<button type="button" class="weui-btn weui-btn_primary f30 receipt">确认收货</button>');
                    htmlText.push('</div>');
                    break;
                case 4:
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<button type="button" class="weui-btn weui-btn_primary f30">再来一单</button>');
                    htmlText.push('</div>');
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="/mobile/comments?sid='+ ldata.shop_id+'&order_id='+ ldata.id +'" style="width: 100%;" class="weui-btn weui-btn_white f30">去评价</a>');
                    htmlText.push('</div>');
                    break;
            }
        } else if (ldata.order_type == 1) {
            switch (ldata.order_status) {
                case 1:
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="/mobile/payment?id='+ ldata.id +'&money='+ ldata. order_price +'&order_type='+ ldata. order_type +'" class="weui-btn weui-btn_primary f30" style="width: 100%;">去支付</a>');
                    htmlText.push('</div>');
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<button type="button" class="weui-btn weui-btn_white f30">取消定单</button>');
                    htmlText.push('</div>');
                    break;
                case 2:
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="javascript:;" id="in-here" data-id="' + ldata.id + '" class="weui-btn weui-btn_primary f30" style="width: 100%;">我已到店</a>');
                    htmlText.push('</div>');
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<button type="button" id="refund" data-id="' + ldata.id + '" class="weui-btn weui-btn_primary weui-btn_white f30">申请退款</button>');
                    htmlText.push('</div>');
                    break;
                case 3:
                    // 呼叫服务员，加菜，结账
                    break;
                case 4:
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="/mobile/comments?sid='+ ldata.shop_id+'&order_id='+ ldata.id +'" style="width: 100%;" class="weui-btn weui-btn_white f30">去评价</a>');
                    htmlText.push('</div>');
                    break;
            }
        } else if (ldata.order_type == 2) {
            switch (ldata.order_status) {
                case 1:
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="/mobile/payment?id='+ ldata.id +'&money='+ ldata. order_price +'&order_type='+ ldata. order_type +'" class="weui-btn weui-btn_primary f30" style="width: 100%;">去支付</a>');
                    htmlText.push('</div>');
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<button type="button" class="weui-btn weui-btn_white f30">取消定单</button>');
                    htmlText.push('</div>');
                    break;
                case 4:
                    // 呼叫服务员，评价
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="/mobile/comments?sid='+ ldata.shop_id+'&order_id='+ ldata.id +'" class="weui-btn weui-btn_white f30" style="width: 100%;">去评价</a>');
                    htmlText.push('</div>');
                    break;
                case 5:

                    break;
                case 6:
                    break;
            }
        } else if (ldata.order_type == 3) {
            switch (ldata.order_status) {
                case 1:
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="/mobile/payment?id='+ ldata.id +'&money='+ ldata. order_price +'&order_type='+ ldata. order_type +'" class="weui-btn weui-btn_primary f30" style="width: 100%;">去支付</a>');
                    htmlText.push('</div>');
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<button type="button" class="weui-btn weui-btn_white f30">取消定单</button>');
                    htmlText.push('</div>');
                    break;
                case 4:
                    // 呼叫服务员，评价
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="/mobile/comments?sid='+ ldata.shop_id+'&order_id='+ ldata.id +'" style="width: 100%;" class="weui-btn weui-btn_white f30">去评价</a>');
                    htmlText.push('</div>');
                    break;
                case 5:

                    break;
                case 6:
                    break;
            }
        }


        htmlText.push('</div>');

        // 显示服务按钮 || ldata.order_type == 3 && ldata.order_status == 4
        if (ldata.order_type == 1 ) {
            if (ldata.order_status == 3) {
                htmlText.push('<div class="btn-round">');
                htmlText.push('<div class="round">');
                htmlText.push('<svg class="icon white" aria-hidden="true">');
                htmlText.push('<use xlink:href="#icon-weibiaoti--26"></use>');
                htmlText.push('</svg>');
                htmlText.push('</div>');
                htmlText.push('<div class="small-round small-round1">');
                htmlText.push('<a href="/mobile/takeout-menu?id='+ ldata.shop_id + '&order_id='+ ldata.id +'&shop_name='+ ldata.shop.shop_name +'&order_type='+ ldata.order_type +'" class="f24 white">加菜</a>');
                htmlText.push('</div>');
                htmlText.push('<div class="small-round small-round2 f24 white service" data-id="'+ ldata.id + '">服务</div>');

                htmlText.push('<div class="small-round small-round3 f24 white pay-money" data-id="'+ ldata.id + '">');
                htmlText.push('<a href="/mobile/payment?id='+ ldata.id +'&money='+ ldata. order_price +'&order_type='+ ldata. order_type +'" class="f24 white">结账</a>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            } else if (ldata.order_status == 2) {
                htmlText.push('<div class="btn-round">');
                htmlText.push('<div class="round">');
                htmlText.push('<p class="white f30 invitation">邀请函</p>');

                htmlText.push('</div>');
                htmlText.push('</div>');
            }

        }
        $(A.root).append(htmlText.join(''));
    },
    // 下单面板
    'takeoutOrder': function (data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        htmlText.push('<div class="order-panel">');
        htmlText.push('<div class="order-header">');
        htmlText.push('<h3 class="shop-name arrow-right">');
        htmlText.push('<svg class="icon f48" aria-hidden="true">');
        htmlText.push('<use xlink:href="#icon-weibiaoti--3"></use>');
        htmlText.push('</svg>');
        htmlText.push('<span class="f36">');
        htmlText.push(data.shops_name);
        htmlText.push('</span>');
        htmlText.push('</h3>');
        htmlText.push('</div>');
        htmlText.push('<div class="order-content">');
        htmlText.push('<div class="foods">');
        console.log("data.desk_room", data.desk_room);
        // 桌子、包间
        if (data.desk_room && data.desk_room.length > 0) {
            var tdata = data.desk_room,
                tlen = tdata.length;
            htmlText.push('<p class="f30 gary9">');
            htmlText.push('桌子：' );
            for (var j = 0; j < tlen; j++) {
                if (tdata[j].type == 0) {
                    htmlText.push(tdata[j].name);
                    htmlText.push('、');
                }

            }
            htmlText.push('</p>');

            htmlText.push('<p class="f30 gary9">');
            htmlText.push('包间：' );
            for (var j = 0; j < tlen; j++) {
                if (tdata[j].type == 1) {
                    htmlText.push(tdata[j].name);
                    htmlText.push('、');
                }

            }
            htmlText.push('</p>');

        }
        // 遍历数据
        var spcePrice = 0, // 多规格价钱
            price = 0, // 原价,计算的时候不*折扣
            discountPrice = 0, // 折扣价,计算的时候会*折扣
            total = 0, // 原总价
            dTotal = 0, // 折后总价
            prePrice = 0; // 优惠价 = 原总价 - 折后总价

        for (var i = 0; i < len; i++) {

            // 对多规格菜进行拆分，
            if (ldata[i].spec) {
                spcePrice = getMoreFoodPrice(ldata[i].spec);
            } else {
                // 如果不是多规格，直接设为0
                spcePrice = 0;
            }

            // 原价 = 商品数量 * (单价 + 多规格价) || 0
            price = parseInt(ldata[i].num) * (parseFloat(ldata[i].price) + spcePrice);

            // 商品价格 = 折扣 * 商品数量 * (单价 + 多规格价) || 0
            discountPrice = parseFloat(ldata[i].discount) * parseInt(ldata[i].num) * (parseFloat(ldata[i].price) + spcePrice); // 计算实价

            total += price; // 原总价
            dTotal += discountPrice;  // 总价

            htmlText.push('<p class="f28 gary9">');
            htmlText.push(ldata[i].dishes_name + ' x' + ldata[i].num);
            if (ldata[i].spec) {
                htmlText.push('<span class="ml-10">');
                htmlText.push(ldata[i].spec);
                htmlText.push('</span>');
            }

            htmlText.push('<span class="f28 gary9 pull-right">');
            htmlText.push('￥' + discountPrice.toFixed(2));
            htmlText.push('</span>');
            htmlText.push('</p>');
        }
        // 计算优惠价 = 原总价 - 总价
        prePrice = (total - dTotal).toFixed(2);
        htmlText.push('<div class="foods-info">');


        // 如果下单类型是外卖,显示配送费
        if (data.order_type === 'takeout') {
            htmlText.push('<p class="f28 gary9">');
            htmlText.push('配送费 <span class="f24 gary9 pull-right spend">￥');
            htmlText.push(data.shops_spend);
            htmlText.push('</span>');
            htmlText.push('</p>');
        }
        htmlText.push('<p class="f28 gary9">');
        htmlText.push('优惠价 <span class="f24 gary9 pull-right prePrice">￥');
        htmlText.push(prePrice);
        htmlText.push('</span>');
        htmlText.push('</p>');

        htmlText.push('<p class="f28 gary9">');
        htmlText.push('总价 <span class="f28 gary9 pull-right total">￥');

        // 如果是外卖，总价要加上配送费
        if (data.order_type === 'takeout') {
            console.log("123456", typeof dTotal) ;
            htmlText.push((dTotal + parseFloat(data.shops_spend)).toFixed(2));
        } else {
            htmlText.push((dTotal).toFixed(2));
        }

        htmlText.push('</span>');
        htmlText.push('</p>');

        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('<div class="order-panel">');
        htmlText.push('<div class="order-header">');
        htmlText.push('<h3 class="f32">备注</h3>');
        htmlText.push('</div>');
        htmlText.push('<div class="order-content">');
        htmlText.push('<textarea name="content" class="content" rows="5" style="width: 100%;border: 1px dashed #dbdbdb;"></textarea>');
        htmlText.push(' </div>');
        htmlText.push(' </div>');
        // 如果是外卖,显示配送信息
        if (data.order_type === 'takeout') {
            console.log("data.addressInfo", data.addressInfo);
            htmlText.push('<div class="order-panel">');
            htmlText.push('<div class="order-header">');
            htmlText.push('<h3 class="f32">配送信息</h3>');
            htmlText.push('</div>');
            htmlText.push('<div class="order-content">');
            htmlText.push('<div class="weui-cells_form">');
            htmlText.push('<div class="weui-cell">');
            htmlText.push('<div class="weui-cell__hd"><label class="weui-label f30">姓名</label></div>');
            htmlText.push('<div class="weui-cell__bd">');
            if (data.addressInfo && data.addressInfo.name) {
                htmlText.push('<input class="weui-input f30" type="text" value="'+ data.addressInfo.name + '"  name="name" placeholder="请输入姓名">');
            } else {
                htmlText.push('<input class="weui-input f30" type="text" value=""  name="name" placeholder="请输入姓名">');
            }

            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell">');
            htmlText.push('<div class="weui-cell__hd"><label class="weui-label f30">手机号</label></div>');
            htmlText.push('<div class="weui-cell__bd">');
            if (data.addressInfo && data.addressInfo.mobile) {
                htmlText.push('<input class="weui-input f30" type="number" value="'+ data.addressInfo.mobile + '" name="phone" placeholder="请输入手机号">');
            } else {
                htmlText.push('<input class="weui-input f30" type="number" value="" name="phone" placeholder="请输入手机号">');
            }

            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell myaddress">');
            htmlText.push('<div class="weui-cell__hd"><label class="weui-label f30">配送地址</label></div>');
            htmlText.push('<a href="/mobile/address?select=1">');
            htmlText.push('<div class="weui-cell__bd arrow-right">');
            if (data.addressInfo && data.addressInfo.address ) {
                htmlText.push('<input class="weui-input gary3 f30" disabled type="text" value="'+ data.addressInfo.address + " " + data.addressInfo.address_detail + '" name="address" placeholder="请选择配送地址">');
                htmlText.push('<input class="weui-input" type="hidden" value="'+ data.addressInfo.id + '" name="addressId">');
            } else {
                htmlText.push('<input class="weui-input gary3 f30" disabled type="text" value="" name="address" placeholder="请选择配送地址">');
                htmlText.push('<input class="weui-input" type="hidden" value="" name="addressId">');
            }

            htmlText.push('</div>');
            htmlText.push('</a>');
            htmlText.push(' </div>');
            htmlText.push(' </div>');
            htmlText.push(' </div>');
            htmlText.push(' </div>');
        } else if (type === 'book'){
            htmlText.push('<div class="order-panel">');
            htmlText.push('<div class="order-header">');
            htmlText.push('<h3 class="f32">预定信息</h3>');
            htmlText.push('</div>');//
            htmlText.push('<div class="order-content">');
            htmlText.push('<div class="weui-cells_form">');
            htmlText.push('<div class="weui-cell">');
            htmlText.push('<div class="weui-cell__hd"><label class="weui-label f30">预定时间</label></div>');
            htmlText.push('<div class="weui-cell__bd">');
            htmlText.push('<input class="weui-input f30" type="text" disabled value="'+ data.arriveTime + '"  name="arriveTime" placeholder="请输入姓名">');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell">');
            htmlText.push('<div class="weui-cell__hd"><label class="weui-label f30">姓名</label></div>');
            htmlText.push('<div class="weui-cell__bd">');
            htmlText.push('<input class="weui-input f30" type="text" value=""  name="name" placeholder="请输入姓名">');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell">');
            htmlText.push('<div class="weui-cell__hd"><label class="weui-label f28">手机号</label></div>');
            htmlText.push('<div class="weui-cell__bd">');
            htmlText.push('<input class="weui-input f30" type="number" value="" name="phone" placeholder="请输入手机号">');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push(' </div>');

        } else if (type === 'sweep') {
            //room_desk_id
            // htmlText.push('<div class="order-panel">');
            // htmlText.push('<div class="order-header">');
            // htmlText.push('<h3 class="f30">点餐信息</h3>');
            // htmlText.push('</div>');
            // htmlText.push('<div class="order-content">');
            // htmlText.push('<div class="weui-cells_form">');
            // htmlText.push('<div class="weui-cell">');
            // htmlText.push('<div class="weui-cell__bd">');
            // htmlText.push('<input class="weui-input f20" type="text" disabled value="'+ data.room_desk_id + '"  name="room_desk_id">');
            // htmlText.push('</div>');
            // htmlText.push('</div>');
            // htmlText.push('</div>');
            // htmlText.push('</div>');
            // htmlText.push('</div>');
            // htmlText.push('</div>');
        }

        htmlText.push('<div class="weui-cell no-border">');
        htmlText.push('<button type="button" class="weui-btn weui-btn_primary f30" onclick="doOrder()">提交</button>');
        htmlText.push('</div>');

        $(A.root).append(htmlText.join(''));
    },
    // 推荐、优惠列表
    'recommendList': function (data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        console.log("ldata", ldata);
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                htmlText.push('<li>');
                htmlText.push('<div class="content weui-flex">');
                htmlText.push('<div class="img">');
                if (ldata[i].thumb) {
                    htmlText.push('<img src="'+ ldata[i].thumb +'" alt="" class="img-responsive">');
                } else {
                    htmlText.push('<img src="/img/eat.png" alt="" class="img-responsive">');
                }

                htmlText.push('</div>');
                htmlText.push('<div class="weui-flex__item">');
                htmlText.push('<div class="text">');
                htmlText.push('<p class="title f28 gary3">');
                htmlText.push(ldata[i].dishes_name);
                htmlText.push('</p>');
                htmlText.push('<p class="summary f24 gary6">简介：墨西哥热浪卷+鸡腿+鸭腿+可乐+冰咖啡+奥尔良烤翅</p>');
                htmlText.push('<p class="24 gary9">');
                htmlText.push('月售'+ ldata[i].sales + '单');
                htmlText.push('</p>');

                htmlText.push('<p class="money f24 gary9">');
                if (ldata[i].discount_price > 0) {
                    htmlText.push('<del>');
                    htmlText.push('原价：' + ldata[i].price);
                    htmlText.push('</del>');
                    htmlText.push('<span class="f36 ml-10">');
                    htmlText.push('￥' + ldata[i].discount_price);
                    htmlText.push('</span>');
                } else {
                    htmlText.push('<span class="f36">');
                    htmlText.push('￥' + ldata[i].price);
                    htmlText.push('</span>');
                }


                htmlText.push('</p>');
                htmlText.push('<a href="/mobile/shopsDetail?id='+ ldata[i].id + '&sid='+ ldata[i].shop_id +'" class="go-buy">去购买</a>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('<div class="shops weui-flex">');
                htmlText.push('<div class="img">');
                if (ldata[i].shop){
                    htmlText.push('<img src="'+ ldata[i].shop.shop_avatar +'" alt="" class="img-responsive">');
                } else {
                    htmlText.push('<img src="/img/shops.jpg" alt="" class="img-responsive">');
                }

                // htmlText.push('<img src="/img/shops.jpg" alt="" class="img-responsive">');
                htmlText.push('</div>');
                htmlText.push('<div class="text">');
                htmlText.push('<p class="title f24 gary3">');
                if (ldata[i].shop){
                    htmlText.push(ldata[i].shop.shop_name);
                }else {
                    htmlText.push('');
                }
                htmlText.push('</p>');
                htmlText.push('<p class="summary f24 gary6 nowrap">');
                if (ldata[i].shop){
                    htmlText.push('简介：' + ldata[i].shop.note);
                }else {
                    htmlText.push('简介：' + '');
                }

                htmlText.push('</p>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</li>');

            }
        }
        // console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    // 银行卡列表
    'bankList': function (data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            for (var i = 0; i < len; i++) {

                ldata[i].account_number = ldata[i].account_number.substr(0,6) + "********" + ldata[i].account_number.substr(-4);

                switch(ldata[i].bank) {
                    case '招商银行':
                        htmlText.push('<a href="javascript:;" id="'+ ldata[i].id +'" class="weui-media-box weui-media-box_appmsg businesf gsyh">');
                        htmlText.push('<div class="col-3">');
                        htmlText.push('<div class="car-logo">');
                        htmlText.push('<svg class="icon f72" aria-hidden="true">');
                        htmlText.push('<use xlink:href="#icon--40"></use>');
                        break;

                    case '中国工商银行':
                        htmlText.push('<a href="javascript:;" id="'+ ldata[i].id +'" class="weui-media-box weui-media-box_appmsg businesf gsyh">');
                        htmlText.push('<div class="col-3">');
                        htmlText.push('<div class="car-logo">');
                        htmlText.push('<svg class="icon f72" aria-hidden="true">');
                        htmlText.push('<use xlink:href="#icon--40"></use>');
                        break;
                    case '中国农业银行':
                        htmlText.push('<a href="javascript:;" id="'+ ldata[i].id +'" class="weui-media-box weui-media-box_appmsg businesf nyyh">');
                        htmlText.push('<div class="col-3">');
                        htmlText.push('<div class="car-logo">');
                        htmlText.push('<svg class="icon f72" aria-hidden="true">');
                        htmlText.push('<use xlink:href="#icon--35"></use>');
                        break;
                    case '中国建设银行':
                        htmlText.push('<a href="javascript:;" id="'+ ldata[i].id +'" class="weui-media-box weui-media-box_appmsg businesf jsyh">');
                        htmlText.push('<div class="col-3">');
                        htmlText.push('<div class="car-logo">');
                        htmlText.push('<svg class="icon f72" aria-hidden="true">');
                        htmlText.push('<use xlink:href="#icon--39"></use>');
                        break;
                    case '中国交通银行':
                        htmlText.push('<a href="javascript:;" id="'+ ldata[i].id +'" class="weui-media-box weui-media-box_appmsg businesf jtyh">');
                        htmlText.push('<div class="col-3">');
                        htmlText.push('<div class="car-logo">');
                        htmlText.push('<svg class="icon f72" aria-hidden="true">');
                        htmlText.push('<use xlink:href="#icon--36"></use>');
                        break;
                    case '中国银行':
                        htmlText.push('<a href="javascript:;" id="'+ ldata[i].id +'" class="weui-media-box weui-media-box_appmsg businesf zgyh">');
                        htmlText.push('<div class="col-3">');
                        htmlText.push('<div class="car-logo">');
                        htmlText.push('<svg class="icon f72" aria-hidden="true">');
                        htmlText.push('<use xlink:href="#icon--38"></use>');
                        break;
                    case '邮政储蓄':
                        htmlText.push('<a href="javascript:;" id="'+ ldata[i].id +'" class="weui-media-box weui-media-box_appmsg businesf yzyh">');
                        htmlText.push('<div class="col-3">');
                        htmlText.push('<div class="car-logo">');
                        htmlText.push('<svg class="icon f72" aria-hidden="true">');
                        htmlText.push('<use xlink:href="#icon--37"></use>');
                        break;

                }
                htmlText.push('</svg>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('<div class="col-9">');
                htmlText.push('<div class="text">');
                htmlText.push('<h4 class="weui-media-box__title f36 white">');
                htmlText.push(ldata[i].bank);
                htmlText.push('</h4>');
                htmlText.push('<p class="card white">储蓄卡</p>');
                htmlText.push('<p class="desc f36 white">');
                htmlText.push(ldata[i].account_number);
                htmlText.push('</p>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</a>');

            }
        }
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));

    },
    // 我的店铺列表
    'storeList': function(data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                htmlText.push('<div class="weui-cells manage">');
                htmlText.push('<div class="weui-cell__bd">');
                htmlText.push('<a href="javascript:;" class="weui-cell_access delete" data-id='+ldata[i].id+' onclick="delStore(this)">&times;');
                htmlText.push('</a>');
                htmlText.push('<div class="weui-cell">');
                htmlText.push('<a class="weui-cell stores" href="/mobile/shopAdmin/store?id='+ ldata[i].id +'">');
                htmlText.push('<div class="weui-cell__hd col-4 login">');
                if (ldata[i].shop_avatar) {
                    htmlText.push('<img src="'+ ldata[i].shop_avatar +'" alt="" >');
                } else {
                    htmlText.push('<img src="/img/eat.png" alt="" >');
                }
                htmlText.push('</div>');
                htmlText.push('<div class="col-12">');
                htmlText.push('<h4 class="weui-media-box__title f30 gary3">');
                htmlText.push(ldata[i].shop_name);
                htmlText.push('</h4>');
                htmlText.push('<p class="relolver f20 gary9">');
                if (ldata[i].note) {
                    htmlText.push(ldata[i].note);
                } else {
                    htmlText.push("没有任何内容");
                }

                htmlText.push('</p>');
                htmlText.push('</div>');
                htmlText.push('</a>');
                //营业开关
                htmlText.push('<div class="weui-cell__ft">');
                if (ldata[i].is_open == 1) {
                    htmlText.push('<input checked data-status="'+ ldata[i].is_open +'" data-id="'+ ldata[i].id +'"  class="weui-switch switch-btn" type="checkbox">');

                } else {
                     htmlText.push('<input data-status="'+ ldata[i].is_open +'" data-id="'+ ldata[i].id +'"  class="weui-switch switch-btn" type="checkbox">');

                }
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</div>');

            }
        }
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    // select 下拉列表
    'optionList': function (data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                if (data.defauleVal === ldata[i].value) {
                    htmlText.push('<option value="'+ ldata[i].value +'" select>');
                } else {
                    htmlText.push('<option value="'+ ldata[i].value +'">');
                }
                htmlText.push(ldata[i].name);
                htmlText.push('</option>');

            }
        }
        console.log("123", htmlText.join(''));
        $(A.root).html(htmlText.join(''));
    } ,
    // 设备列表
    'equipmentlist': function(data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                htmlText.push(' <div class="site weui-cells_checkbox">');
                htmlText.push('<a class="weui-cell_access  deletet" href="javascript:; "id="del" data-sid='+ ldata[i].shop_id +' data-id=' + ldata[i].id+'>&times;');
                htmlText.push('</a>');
                htmlText.push(' <a class="weui-cell weui-cell_access manager" href="/mobile/shopAdmin/facility?rid='+ ldata[i].id +'&sid='+ ldata[i].shop_id+' ">');
                htmlText.push(' <div class="weui-cell__bd weui-cell_primary">');
                htmlText.push(' <p>'+ ldata[i].department );
                htmlText.push(' </p>');
                htmlText.push(' </div>');
                htmlText.push(' <span class="weui-cell__ft">');
                htmlText.push(' </span>');
                htmlText.push(' </a>');
                htmlText.push(' </div>');
            }
        }
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },

    //员工管理
    'employees': function(data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                htmlText.push(' <div class="weui-pay append">');
                htmlText.push(' <div class="site weui-cells_checkbox">');
                htmlText.push(' <div class="weui-media-box weui-media-box_appmsg ">');
                htmlText.push(' <div class="weui-cell__hd nameand ">');
                if (ldata[i].avatar) {
                    htmlText.push('<img src="'+ ldata[i].avatar+ '" alt="" >');
                } else {
                    //htmlText.push('<img src="/img/POP.png" alt="" >');
                    htmlText.push('<div class="weui-cell__hd nameand ">');
                    htmlText.push('<svg class="icon f80 white" aria-hidden="true">');
                    htmlText.push('<use xlink:href="#icon-renxiang">');
                    htmlText.push('</use>');
                    htmlText.push('</svg>');
                    htmlText.push('</div>');
                }
                htmlText.push(' </div>');
                htmlText.push(' <div class="weui-media-box__bd ">');
                htmlText.push(' <h4 class="weui-media-box__title f30 fu10">姓名:');
                htmlText.push(ldata[i].name);
                htmlText.push(' </h4>');
                htmlText.push(' <h4 class="weui-media-box__title f30 fu10">职位:');
                //判断值=0  1 2 3对应的名称 0财务，1服务员，2经理，3主管
                   if(ldata[i].role == 0){
                       htmlText.push("财务");
                   }  else if (ldata[i].role == 1) {
                       htmlText.push("前台");
                   }
                   else if (ldata[i].role == 2) {
                       htmlText.push("后厨");
                   }
                   else if (ldata[i].role == 3) {
                       htmlText.push("服务员");
                   }
                htmlText.push('</h4>');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__bd mebto">');
                htmlText.push('<svg class="icon f40 gary3" aria-hidden="true">');
                htmlText.push('<use xlink:href="#icon-weibiaoti--24">');
                htmlText.push('</use>');
                htmlText.push('</svg>');
                htmlText.push('<div class="btn-group">');
                htmlText.push('<a href="javascript:;"  data-sid='+ ldata[i].shop_id +' data-id=' + ldata[i].id+' class="weui-btn weui-btn_mini weui-btn_primary edit">修改');
                htmlText.push('</a>');
                htmlText.push('<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary"  data-sid='+ ldata[i].shop_id +' data-id=' + ldata[i].id+' id="del">删除');
                htmlText.push('</a>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            }
        }
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    //员工详情
    'details': function(data) {
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;
            htmlText.push('<div class="weui-panel__bd ">');
            htmlText.push('<a href="javascript:;">');
            htmlText.push('<div class="weui-flex  details ">');
            htmlText.push('<label class="face-img" for="uploaderInput">');
            if (ldata.avatar) {
                htmlText.push('<img src="'+ ldata.avatar+ '" alt="" >');
            } else {
                htmlText.push('<img src="/img/erha.png" alt="" >');
            }

            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-uploader__input-box pull-right" style="display: none;">');
            htmlText.push('<form action="" id="img-form">');

            //htmlText.push('<input id="uploaderInput" name="thumb" class="weui-uploader__input" type="file" accept="image/*" multiple="" onchange="saveImg('/uploadImg', '#img-form', showHead)">');


            htmlText.push('</form>');
            htmlText.push('</div>');
            htmlText.push('</a>');
            htmlText.push('</div>');

            htmlText.push('<div class="weui-pay append">');
            htmlText.push('<div class="site weui-cells_checkbox">');
            htmlText.push('<div class="weui-cell ">');
            htmlText.push('<div class="weui-cell__hd">');
            htmlText.push('<label for="name" >证件号:');
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__bd">');
            //name="employeeId"
            htmlText.push('<input class="weui-input"  disabled="disabled" value="'+ ldata.employeeId +'" placeholder="911-101">');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('</div>');

            htmlText.push('<div class="site weui-cells_checkbox">');
            htmlText.push('<div class="weui-cell ">');
            htmlText.push('<div class="weui-cell__hd">');
            htmlText.push('<label for="name">姓名:');

            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__bd" >');
            htmlText.push('<input class="weui-input" name="name"  value="'+ ldata.name +'" placeholder="哈士奇">');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('<div class="site weui-cells_checkbox">');
            htmlText.push('<div class="weui-cell ">');
            htmlText.push('<div class="weui-cell__hd">');
            htmlText.push('<label for="name">性别:');
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__bd">');
            htmlText.push('<div class="weui-cell__bd">');
            htmlText.push('<select class="weui-select" name="sex">');
                if (ldata.sex == 0){
                    htmlText.push(' <option value="0" selected >男');
                    htmlText.push(' </option>');
                    htmlText.push(' <option value="1">女');
                    htmlText.push(' </option>');
                }  else if(ldata.sex == 1){
                    htmlText.push(' <option  value="1" selected>女');
                    htmlText.push(' </option>');
                    htmlText.push(' <option value="0">男');
                    htmlText.push(' </option>');
                }
            htmlText.push(' </select>');
            htmlText.push(' </div>');
            htmlText.push(' </div>');
            htmlText.push(' <div class="weui-cell__dd">');
            htmlText.push(' <svg class="icon f40" aria-hidden="true">');
            htmlText.push(' <use xlink:href="#icon--34">');
            htmlText.push(' </use>');
            htmlText.push(' </svg>');
            htmlText.push(' </div>');
            htmlText.push(' </div>');
            htmlText.push(' </div>');
            htmlText.push(' <div class="site weui-cells_checkbox">');
            htmlText.push(' <div class="weui-cell ">');
            htmlText.push(' <div class="weui-cell__hd">');
            htmlText.push(' <label for="name">职位:');
            htmlText.push(' </label>');
            htmlText.push(' </div>');
            htmlText.push(' <div class="weui-cell__bd">');
            htmlText.push(' <select class="weui-select" name="role">');

            if (ldata.role == 0) {
                htmlText.push(' <option value="0" selected>财务');
                htmlText.push(' </option>');
                htmlText.push(' <option value="1">服务员');
                htmlText.push(' </option>');
                htmlText.push(' <option value="2">经理');
                htmlText.push(' </option>');
                htmlText.push(' <option value="3">主管');
                htmlText.push(' </option>');
            } else if (ldata.role == 1) {
                htmlText.push(' <option value="0" >财务');
                htmlText.push(' </option>');
                htmlText.push(' <option value="1">服务员');
                htmlText.push(' </option>');
                htmlText.push(' <option value="2">经理');
                htmlText.push(' </option>');
                htmlText.push(' <option value="3">主管');
                htmlText.push(' </option>');
            } else if (ldata.role == 2) {
                htmlText.push(' <option value="0" >财务');
                htmlText.push(' </option>');
                htmlText.push(' <option value="1">服务员');
                htmlText.push(' </option>');
                htmlText.push(' <option value="2">经理');
                htmlText.push(' </option>');
                htmlText.push(' <option value="3">主管');
                htmlText.push(' </option>');
            }  else if (ldata.role == 3) {
                htmlText.push(' <option value="0">财务');
                htmlText.push(' </option>');
                htmlText.push(' <option value="1">服务员');
                htmlText.push(' </option>');
                htmlText.push(' <option value="2">经理');
                htmlText.push(' </option>');
                htmlText.push(' <option value="3">主管');
                htmlText.push(' </option>');
            }



            htmlText.push(' </select>');
            htmlText.push(' </div>');
            htmlText.push(' <div class="weui-cell__dd">');
            htmlText.push(' <svg class="icon f40" aria-hidden="true">');
            htmlText.push(' <use xlink:href="#icon--34">');
            htmlText.push(' </use>');
            htmlText.push(' </svg>');
            htmlText.push(' </div>');
            htmlText.push(' </div>');
            htmlText.push(' </div>');
            htmlText.push(' <div class="demos-content-padded">');
            htmlText.push(' <a href="javascript:;" class="weui-btn weui-btn_blue open-popup">保存');
            htmlText.push(' </a>');
            htmlText.push(' </div>');
            htmlText.push(' </div>');

        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    //商家管理所有订单
    'managementh': function(data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                htmlText.push('<div class="site weui-cells_checkbox">');
                htmlText.push('<a class="Detailed" href="/mobile/shopAdmin/enewstore?id='+ ldata[i].id +'&order_type='+ ldata[i].order_type +'">');
                htmlText.push('<div class="weui-cell weui-cells f24">');
                htmlText.push('<div class="weui-cell__bd ">');
                htmlText.push('<p>订单号:');
                htmlText.push(ldata[i].order_number);
                htmlText.push('</p>');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__ft ">');
                if (ldata[i].order_type == 0) {
                    // peisong
                    htmlText.push(ldata[i].created_at);
                } else if (ldata[i].order_type == 1) {
                    // yuding
                    htmlText.push('预定时间 ');
                    htmlText.push(ldata[i].created_at);
                } else if(ldata[i].order_type == 2){
                    htmlText.push('已等待 ');
                    htmlText.push(ldata[i].created_at);
                }

                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell ">');
                htmlText.push('<div class="weui-cell__hd">');
                htmlText.push('<label for="name">订单金额:');
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__hd">');
                htmlText.push('<label for="name">');
                htmlText.push(ldata[i].order_price);
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                //排队就餐人数
                if(ldata[i].order_type == 2){
                    htmlText.push('<div class="weui-cell ">');
                    htmlText.push('<div class="weui-cell__hd">');
                    htmlText.push('<label for="name">就餐人数:');
                    htmlText.push('</label>');
                    htmlText.push('</div>');
                    htmlText.push('<div class="weui-cell__hd">');
                    htmlText.push('<label for="name">');
                    htmlText.push(ldata[i].qorder.people);
                    htmlText.push('</label>');
                    htmlText.push('</div>');
                    htmlText.push('</div>');
                }

                if (ldata[i].order_type == 1) {
                    htmlText.push('<div class="weui-cell ">');
                    htmlText.push('<div class="weui-cell__hd">');
                    htmlText.push('<label for="name">预订房间:');


                    htmlText.push('</label>');
                    htmlText.push('</div>');
                    htmlText.push('<div class="weui-cell__hd">');
                    htmlText.push('<label for="name">');
                    if(ldata[i].order_type == 0){
                        htmlText.push(ldata[i].rorder.show_table);
                    }

                    htmlText.push('</label>');
                    htmlText.push('</div>');
                    htmlText.push('</div>');
                } else {

                }

                htmlText.push('<div class="weui-cell ">');
                htmlText.push('<div class="weui-cell__hd">');

                htmlText.push('<label for="name">下单时间:');
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__hd">');
                htmlText.push('<label for="name">18-05-20 12:00');
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell ">');
                htmlText.push('<div class="weui-cell__hd">');
                htmlText.push('<label for="name">下单人:');
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__hd">');
                htmlText.push('<label for="name">');
                htmlText.push(ldata[i].users.name);
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell ">');
                htmlText.push('<div class="weui-cell__hd">');
                if(ldata[i].order_type == 0){
                    htmlText.push('联系方式:');
                }   else if(ldata[i].order_type == 1 ) {
                    htmlText.push('联系方式:');
                }   else if(ldata[i].order_type == 2 ) {
                    htmlText.push('排队号:');
                }
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__hd">');
                htmlText.push('<label for="name">');
                if (ldata[i].order_type == 0) {
                    //配送
                    if (ldata[i].order_address) {
                        htmlText.push(ldata[i].order_address.mobile);
                    }

                } else if (ldata[i].order_type == 1){
                    //预订
                    if (ldata[i].rorder) {
                        htmlText.push(ldata[i].rorder.phone);
                    }

                } else if(ldata[i].order_type == 2){
                    //排队
                    htmlText.push(ldata[i].qorder.number);
                } else if(ldata[i].order_type == 3){

                }
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                if( ldata[i].order_type == 0){
                    htmlText.push('<div class="weui-cell ">');
                    htmlText.push('<div class="weui-cell__hd">');
                    htmlText.push('<label for="name">备注:');
                    htmlText.push('</label>');
                    htmlText.push('</div>');
                    htmlText.push('<div class="weui-cell__hd">');
                    htmlText.push('<label for="name">');
                    //htmlText.push(ldata[i].users.note);
                    htmlText.push('</label>');
                    htmlText.push('</div>');
                    htmlText.push('</div>');
                }
                htmlText.push('</a>');
                htmlText.push('</div>');
            }
        }
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    //订单详情
    'lineiteml': function(data) {
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;
            htmlText.push('<div class="siteH weui-cells_checkbox fu2">');
            htmlText.push('<div class="weui-cell weui-cells">');
            htmlText.push('<div class="weui-cell__hd fu10">');
            htmlText.push('<label for="name">订单号');
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('<p class="gary9 order-number">');
            htmlText.push(ldata.order_number);
            htmlText.push('</p>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell cellsa">');
            htmlText.push('<div class="weui-cell__hd fu10">');
            htmlText.push('<label for="name">金额¥');
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__hd gary9">');
            htmlText.push('<label for="name">');
            htmlText.push(ldata.order_price);
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell ">');
            htmlText.push('<div class="weui-cell__hd ">');
            htmlText.push('<label for="name">下单时间:');
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__hd gary9">');
            htmlText.push('<label for="name">');
            htmlText.push(ldata.created_at);
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            //预订=1  显示就餐时间
             if(ldata.order_type === 1) {
                 htmlText.push('<div class="weui-cell ">');
                 htmlText.push('<div class="weui-cell__hd cellsa">');
                 htmlText.push('<label for="name">用餐时间:');
                 htmlText.push('</label>');
                 htmlText.push('</div>');
                 htmlText.push('<div class="weui-cell__hd gary9">');
                 htmlText.push('<label for="name">');
                 htmlText.push(ldata.created_at);
             }



            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            //预订
            if(ldata.order_type ===1){
                htmlText.push('<div class="weui-cell ">');
                htmlText.push('<div class="weui-cell__hd ">');
                htmlText.push('<label for="name">房间/桌号');
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__hd gary9">');
                htmlText.push('<label for="name">');
                htmlText.push(ldata.order_reserve.desk_room);

                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            }else if(ldata.order_type ===1){

            }

            htmlText.push('<div class="weui-cells thene_ybk">');
            if(ldata.order_status === 1){
                htmlText.push('<div class="weui-cell">');
                htmlText.push('<div class="weui-cell__hd cellsa ">');
                htmlText.push('<label for="name">点菜信息');
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            } else if(ldata.order_status === 2){
                htmlText.push('<div class="weui-cell">');
                htmlText.push('<div class="weui-cell__hd cellsa ">');
                htmlText.push('<label for="name">点菜信息');
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            }   else if(ldata.order_status === 3){
                htmlText.push('<div class="weui-cell">');
                htmlText.push('<div class="weui-cell__hd cellsa ">');
                htmlText.push('<label for="name">点菜信息');
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            }    else if(ldata.order_status === -1){
                htmlText.push('<div class="weui-cell">');
                htmlText.push('<div class="weui-cell__hd cellsa ">');
                htmlText.push('<label for="name">点菜信息');
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            }     else if(ldata.order_status === -2){
                htmlText.push('<div class="weui-cell">');
                htmlText.push('<div class="weui-cell__hd cellsa ">');
                htmlText.push('<label for="name">点菜信息');
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            }
            if (ldata.order_detail && ldata.order_detail.length > 0) {
                var fdata = ldata.order_detail,
                    len = fdata.length,
                    spcePrice = 0;

                for (var i = 0; i < len; i++) {


                    htmlText.push('<div class="weui-cell datakosr  ">');
                    htmlText.push('<div class="weui-cell__bd gary9 ">');
                    htmlText.push('<label for="name">');
                    htmlText.push(fdata[i].dishes_name + 'x' + fdata[i].goods_number);
                    htmlText.push('</label>');
                    htmlText.push('</div>');
                    htmlText.push('<div class="weui-cell__ft">');
                    // 对多规格菜进行拆分，
                    if (fdata[i].spec) {
                        spcePrice = getMoreFoodPrice(fdata[i].spec);
                        htmlText.push('<span class="ml-10">');
                        htmlText.push(fdata[i].spec);
                        htmlText.push('</span>');
                        htmlText.push('<span>');
                        htmlText.push('￥' + (fdata[i].price));
                        htmlText.push('</span>');

                    } else {
                        // 如果不是多规格，直接设为0
                        spcePrice = 0;
                        htmlText.push('<span>');
                        htmlText.push('￥' + (fdata[i].price));
                        htmlText.push('</span>');

                    }

                    htmlText.push('</div>');
                    htmlText.push('</div>');



                }


            }




            //htmlText.push('<div class="weui-cell  datakosr ">');
            //htmlText.push('<div class="weui-cell__bd">');
            //htmlText.push('<label for="name">');
            //htmlText.push(ldata.order_detail.dishes_name);
            //htmlText.push('</label>');
            //htmlText.push('</div>');
            //htmlText.push('<div class="weui-cell__ft">');
            //htmlText.push('<span>¥0');
            //htmlText.push('</span>');
            //htmlText.push('</div>');
            //htmlText.push('</div>');
            //
            if(ldata.order_type === 1){
                htmlText.push('<div class="weui-cell cellsa">');
                htmlText.push('<div class="weui-cell__hd fu12">下单人');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__hd gary9">');
                htmlText.push('<label for="name">');
                htmlText.push(ldata.users.name);
                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            }else if(ldata.order_type === 0){
                htmlText.push('<div class="weui-cell cellsa">');
                htmlText.push('<div class="weui-cell__hd fu12">收货地址');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__hd gary9">');
                htmlText.push('<label for="name">');
                htmlText.push(ldata.address);

                htmlText.push('</label>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            }


            htmlText.push('<div class="weui-cell cellsa">');
            htmlText.push('<div class="weui-cell__hd fu8">联系方式');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__hd gary9">');

            if(ldata.order_type === 1) {
                htmlText.push('<a class="gary9" for="name" href="tel:' + ldata.order_reserve.phone + '">');
                htmlText.push('<label for="name">');
                htmlText.push(ldata.order_reserve.phone);
                htmlText.push('</label>');
                htmlText.push('</a>');
                //htmlText.push('<label for="name">');
                //htmlText.push(ldata.order_reserve.phone);
                //htmlText.push('</label>');
            } else if(ldata.order_type === 0){

                if(ldata.order_reserve){
                    //htmlText.push(ldata.order_reserve.phone);
                    htmlText.push('<a class="gary9" for="name" href="tel:' + ldata.order_reserve.phone + '">');
                    htmlText.push(ldata.order_reserve.phone);
                    htmlText.push('</a>');
                }

            }
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('</div>');








            htmlText.push('<div class="weui-cell cellsa ">');
            htmlText.push('<div class="weui-cell__hd fu20">备注');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__hd gary9">');
            htmlText.push('<label for="name">');
            htmlText.push(ldata.note);
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            if(ldata.order_status === -3){
                htmlText.push('<div class="weui-cell ">');
                htmlText.push('<div class="weui-cell__hd fu20 gary9">已退款');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            }


            if(ldata.order_type === 1){
                if(ldata.order_status === -1){
                    htmlText.push('<div class="btn-group">');
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="javascript:;" class="weui-btn weui-btn_primary f30" id="hasbeena" style="width: 100%;">同意退款');
                    htmlText.push('</a>');
                    htmlText.push('</div>');
                    htmlText.push('</div>');

                }else if(ldata.order_status === 2){
                    //客人已到店
                    htmlText.push('<div class="btn-group">');
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="javascript:;" class="weui-btn weui-btn_primary f30" id="beento" style="width: 100%;">已到店')
                    htmlText.push('</a>');
                    htmlText.push('</div>');
                    htmlText.push('</div>');
                }

                else if(ldata.order_status === 3){
                    //加菜
                    htmlText.push('<div class="btn-group">');
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="/mobile/shopAdmin/sidedish?sid='+ ldata.shop_id+'&order_id='+ldata.id+'"  class="weui-btn weui-btn_primary f30" id="sidedish" style="width: 100%;">加菜')
                    htmlText.push('</a>');
                    htmlText.push('</div>');
                    htmlText.push('</div>');
                    //修改价格
                    htmlText.push('<div class="btn-group">');
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="javascript:;" class="weui-btn weui-btn_primary f30" id="revisethe" style="width: 100%;">修改订单价格')
                    htmlText.push('</a>');
                    htmlText.push('</div>');
                    htmlText.push('</div>');
                }
                else if(ldata.order_status === -1){
                    //申请退款-1
                    htmlText.push('<div class="btn-group">');
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="javascript:;" class="weui-btn weui-btn_primary f30" id="merchant" style="width: 100%;">同意退款');
                    htmlText.push('</a>');
                    htmlText.push('</div>');
                    htmlText.push('</div>');
                } else  if(ldata.order_status === -2){
                    //已退款-2
                    htmlText.push('<div class="weui-cell ">');
                    htmlText.push('<div class="weui-cell__hd fu20 gary9">已退款');
                    htmlText.push('</div>');
                    htmlText.push('</div>');
                    htmlText.push('</div>');
                }
            }else if (ldata.order_type === 0){
                //订单 order_status= 2 确认接单
                if(ldata.order_status === 2){
                    htmlText.push('<div class="btn-group">');
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="javascript:;" class="weui-btn weui-btn_primary f30" id="confirm" style="width: 100%;">确认接单');
                    htmlText.push('</a>');
                    htmlText.push('</div>');
                    htmlText.push('</div>');

                }else if(ldata.order_status === 3){
                    //订单 order_status= 3 已接单正在处理订单
                    htmlText.push('<div class="weui-cell ">');
                    htmlText.push('<div class="weui-cell__hd fu20 gary9">正在处理订单');
                    htmlText.push('</div>');
                    htmlText.push('</div>');
                    htmlText.push('</div>');

                }  else if(ldata.order_status === -1){
                    //申请退款  order_status = -1 同意退款
                    htmlText.push('<div class="btn-group">');
                    htmlText.push('<div class="weui-cell no-border">');
                    htmlText.push('<a href="javascript:;" class="weui-btn weui-btn_primary f30" id="agree" style="width: 100%;">同意退款');
                    htmlText.push('</a>');
                    htmlText.push('</div>');
                    htmlText.push('</div>');
                }

            }


            htmlText.push('</div>');



        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    //邀请函
    'thenumber1': function(data) {
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;
        htmlText.push('<div class="invitati">');
        htmlText.push('<div class="invitation">');
        htmlText.push('<div class="demos-content-padded circle">');
        htmlText.push('<div class="demos-ofcolor">');
        htmlText.push('<div class="demos-header">');
        htmlText.push('<p class="demos-title"> I have not forgotten you !');
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header figure">');
        htmlText.push('<ul class="weui-uploader__files">');
        htmlText.push('<li class="letter">邀请函');
        htmlText.push('</li>');
        htmlText.push('</ul>');
        htmlText.push('<img class="" src="/img/haha.png" alt="">');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header ">');
        htmlText.push('<p class="demos-title zenlk"> 这是个宴会邀请函');
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header ">');
        htmlText.push('<p class="demos-title zenlk1">');
        htmlText.push(ldata.invitation.updated_at);
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header ">');
        htmlText.push('<p class="demos-title zenlk2">');

        htmlText.push(ldata.Shop.shop_address);
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header ">');
        htmlText.push('<div class="weui-cell map">');
        htmlText.push('<div class="googleMap" >');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header ">');
        htmlText.push('<ul class="zenlk3">');
        //htmlText.push('<li class="number_the">00');
        //htmlText.push('</li>');
        htmlText.push('<li class="number">');
        htmlText.push(ldata.invitation.content);
        htmlText.push('</li>');
        htmlText.push('</ul>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    'thenumber2': function(data) {
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;
        htmlText.push('<div class="<div class="invitation_1">');
        htmlText.push('<div class="demos-content-padded circle">');
        htmlText.push('<div class="demos-ofcolor_1">');
        htmlText.push('<div class="demos-header">');
        htmlText.push('<p class="demos-title_1"> lt s an invitation to my birthday party ');
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header figure_1">');
        htmlText.push('<img src="/img/srt.png" alt="">');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header figure_s1">');
        htmlText.push('<img  src="/img/aq.png" alt="">');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header ">');
        htmlText.push('<p class=" srzenlk"> 邀请你参加我的生日宴会');
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header ">');
        htmlText.push('<p class="srzenlk_1 f36">');
        htmlText.push(ldata.invitation.updated_at);
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header ">');
        htmlText.push('<p class="srzenlk_1 f36">');
        htmlText.push(ldata.Shop.shop_address);
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header ">');
        htmlText.push('<div class="weui-cell map">');
        htmlText.push('<div class="googleMap">');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header ">');
        htmlText.push('<ul class="zenlk4">');
        //htmlText.push('<li class="number_the">00');
        //htmlText.push('</li>');
        htmlText.push('<li class="number">');
        htmlText.push(ldata.invitation.content);
        htmlText.push('</li>');
        htmlText.push('</ul>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    'thenumber3': function(data) {
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;
        htmlText.push('<div class="invitation_2">');
        htmlText.push('<div class="demos-content-padded circle">');
        htmlText.push('<div class="demos-ofcolor_2">');
        htmlText.push('<div class="demos-header">');
        htmlText.push('<p class="demos-title_2">WE GOT MARRIED! ');
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header figure_2">');
        htmlText.push('<img src="/img/yqhq.png" alt="">');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header figure_s2">');
        htmlText.push('<img src="/img/aq.png" alt="">');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header ">');
        htmlText.push('<p class=" srzenlk_2"> 婚礼邀请函');
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('<div class="weui-footer demos-header">');
        htmlText.push('<p class="weui-footer__links">');
        htmlText.push('<a class="weui-footer__link ">波波皮');
        htmlText.push('</a>');
        htmlText.push('<a class="weui-footer__link">皮皮波');
        htmlText.push('</a>');
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header ">');
        htmlText.push('<p class="srzenlk_1">');
        htmlText.push(ldata.invitation.updated_at);
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('<div class="demos-header map_2">');
        htmlText.push('<div class="weui-cell map">');
        htmlText.push('<div class="googleMap">');
        htmlText.push('<div class="weui-cell ">');
        htmlText.push('<div class="weui-cell__hd">');
        htmlText.push('<label for="name">时间:');
        htmlText.push(ldata.invitation.updated_at);
        htmlText.push('</label>');
        htmlText.push('</div>');
        htmlText.push('<div class="weui-cell__hd">');

        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('<div class="weui-cell ">');
        htmlText.push('<div class="weui-cell__hd">');
        htmlText.push('<label for="name">地址:');
        htmlText.push(ldata.Shop.shop_address);
        htmlText.push('</label>');
        htmlText.push('</div>');
        htmlText.push('<div class="weui-cell__hd">');
        htmlText.push('<label for="name">');

        htmlText.push('</label>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('<div class="weui-cell ">');
        htmlText.push('<div class="weui-cell__hd">');
        htmlText.push('<label for="name">房间:');
        htmlText.push('</label>');
        htmlText.push('</div>');
        htmlText.push('<div class="weui-cell__hd">');
        htmlText.push('<label for="name">火星人');
        htmlText.push('</label>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('<div class="weui-cell map_2">');
        htmlText.push('<div class="googleMap">');
        htmlText.push('<div class="weui-cell">');
        htmlText.push('<div class="weui-cell__bd dshuo_dz">');
        htmlText.push('<img src="/img/banner1.png" alt="">');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('<div class="weui-cell">');
        htmlText.push('<div class="weui-cell__bd dshuo_dzhl">');
        htmlText.push('<div class=" weui-dialog--visible">');
        htmlText.push('<div class="weui-dialog__hd">');
        htmlText.push('<strong class="weui-dialog__title">');
        htmlText.push(ldata.invitation.content);
        htmlText.push('</strong>');
        htmlText.push('</div>');
        htmlText.push('<div class="button_sp_area embers">');
        htmlText.push('<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary">我不方便');
        htmlText.push('</a>');
        htmlText.push('<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_default">确认出席');
        htmlText.push('</a>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    //充值卡
    'fillcard': function(data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                htmlText.push('<div class="prepaity">');
                //payment  支付页面链接/mobile/payment
                htmlText.push('<a href="javascript:;"  class="weui-media-box weui-media-box_appmsg prepaity_cz dd_czk">');
                htmlText.push('<div class="weui-media imgbor ">');
                htmlText.push('<div class="imgboreh">');
                htmlText.push('<div class="minilogo">');
                htmlText.push('<img class="" src="/img/logo2.png" alt="">');
                htmlText.push('</div>');
                htmlText.push('<div class="minilogo">');
                htmlText.push('<h4 class="direct fu12 ">掌里通智慧城市');
                htmlText.push('</h4>');
                htmlText.push('</div>');
                htmlText.push('<div>');
                htmlText.push('<h1 class="direct_mi" name="money">');
                htmlText.push(ldata[i].money);
                htmlText.push('</h1>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</a>');
                htmlText.push('<header class="demos-header">');
                htmlText.push('<h1 class=" Card " name="title">');
                htmlText.push(ldata[i].title);
                htmlText.push('</h1>');
                htmlText.push('</header>');
                htmlText.push('</div>');
            }
        }
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    //活动
    'tivity': function(data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                htmlText.push('<a class="weui-cell weui-cell_access" href="/mobile/activityk?id='+ ldata[i].id +'">');
                htmlText.push('<div class="weui-cell__hd">');
                if (ldata.image) {
                    htmlText.push('<img src="'+ ldata.image+ '" alt="" style="width: 100%;" >');
                } else {

                    htmlText.push('<img src="/img/czk.png" style="width: 100%; alt="">');
                }
                htmlText.push('</div>');
                htmlText.push('</a>');
                htmlText.push('<div class="weui-cells__title activity_bt">');
                htmlText.push(ldata[i].title);
                htmlText.push('</div>');
            }
        }
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    //活动详情
    'tivityk': function(data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;
        htmlText.push('<div class="weui-flex">');
        htmlText.push('<label class="face-img" for="uploaderInput">');
        //if (data.image) {
        //    htmlText.push('<img src="'+ ldata.image+ '" alt="" style="width: 100%;" >');
        //} else {
        //
        //    htmlText.push('<img src="/img/gywm.png" style="width: 100%; alt="">');
        //}
        //htmlText.push('<img src="/img/gywm.png" alt="" style="width: 100%">');
        htmlText.push('</label>');
        htmlText.push('</div>');
        htmlText.push('<div class="weui-cell__bd">');
        htmlText.push('<p>');
        htmlText.push('<svg class="icong f40" aria-hidden="true">');
        htmlText.push('<use xlink:href="#icon-tubiaozhizuomobanyihuifu-">');
        htmlText.push('</use>');
        htmlText.push('</svg>');


        htmlText.push(ldata.content);
        htmlText.push('</p>');
        htmlText.push('</div>');
        htmlText.push('<div class="weui-cell__bd">');
        htmlText.push('<p>');
        htmlText.push('<svg class="icong f40 " aria-hidden="true">');
        htmlText.push('<use xlink:href="#icon-tubiaozhizuomobanyihuifu-">');
        htmlText.push('</use>');
        htmlText.push('</svg>');
        htmlText.push(ldata.description);

        htmlText.push('</p>');
        htmlText.push('</div>');

        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },


    //菜单管理
    'context': function(data) {

        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                htmlText.push('<div class="menuib">');
                htmlText.push('<a class="weui-cell_access  deletet" href="javascript:; " id="del" data-id="'+ ldata[i].id + '">&times;');
                htmlText.push('</a>');

                htmlText.push('<a id="hca" class="menua  weui-btn_default" href="/mobile/shopAdmin/storeHCA?id='+ ldata[i].id +'&sid='+ ldata[i].shop_id +'" >');
                htmlText.push('<div class="weui-cell__hd login">');
                if (ldata[i].thumb) {
                    htmlText.push('<img src="'+ ldata[i].thumb  + '" alt="" >');
                } else {
                    htmlText.push('<img src="/img/eat.png" alt="" >');
                }
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell">');
                htmlText.push('<p class="dishnames ">');
                htmlText.push(ldata[i].dishes_name);
                htmlText.push('</p>');
                htmlText.push('<p class="inshnames">¥');
                htmlText.push(ldata[i].price);
                htmlText.push('</p>');
                htmlText.push('</div>');
                htmlText.push('</a>');


                if(ldata[i].status == 0 ){
                    htmlText.push('<a href="javascript:;" data-id="'+ ldata[i].id + '" data-status="'+ ldata[i].status + '" class="weui-btn weui-btn_mini weui-btn_default" id="putaway">上架');
                    htmlText.push('</a>');
                }else if(ldata[i].status == 1 ){
                    htmlText.push('<a href="javascript:;" data-id="'+ ldata[i].id + '" data-status="'+ ldata[i].status + '" class="weui-btn weui-btn_mini weui-btn_default" id="putaway">下架');
                    htmlText.push('</a>');
                }


                htmlText.push('</div>');

            }
        }
        console.log("123", htmlText.join(''));
        $(A.root).before(htmlText.join(''));
    },
    //房桌管理
    'roomtable': function(data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                htmlText.push('<div class="tab-contenty">');
                htmlText.push('<div class="tab-pane active" id="1">');
                htmlText.push('<div class="weui-cells ">');

                htmlText.push('<a href="javascript:;" class="weui-cell_access delete" data-sid='+ ldata[i].shop_id +' data-id=' + ldata[i].id+' id="del">&times;');
                htmlText.push('</a>');

                htmlText.push('<a class="weui-cell weui-cell_access " href="/mobile/shopAdmin/rodeletethe?id='+ ldata[i].id+'&sid='+ldata[i].shop_id+'">');
                htmlText.push('<div class="weui-cell__hd ">');


                if (ldata[i].thumb) {
                    htmlText.push('<img class="head_top" src="'+ ldata[i].thumb + '" alt="" >');
                }else{
                    htmlText.push('<img class="head_top" src="/img/erha.png">');
                }


                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__bd weui-cell_primary princess">');
                htmlText.push('<p>');
                htmlText.push(ldata[i].name);
                htmlText.push('</p>');
                htmlText.push('</div>');
                if(ldata [i].type  == 1 ){
                    htmlText.push('<div class="weui-cell__bd">包间');
                    htmlText.push('</div>');
                }else if(ldata[i].type == 0 ){
                    htmlText.push('<div class="weui-cell__bd">大厅');
                    htmlText.push('</div>');
                }

                htmlText.push('<span class="weui-cell__ft">');
                if(ldata[i].is_use == 0){
                    htmlText.push('未使用');
                }else if(ldata[i].is_use == 1){
                    htmlText.push('使用中');
                }
                htmlText.push('</span>');


                htmlText.push('</a>');

                htmlText.push('</div>');
                htmlText.push('</div>');

                htmlText.push('</div>');
            }
        }
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    //明细
    'billing': function(data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                htmlText.push('<div class="tab-content billing">');
                htmlText.push('<div class="tab-pane active" id="1">');
                htmlText.push('<div class="weui-cells ">');
                //htmlText.push('<a href="javascript:;" class="weui-cell_access delete" data-sid="1" data-id="15" id="del">×');
                //htmlText.push('</a>');
                htmlText.push('<a class="weui-cell weui-cell_access " href="/mobile/remation?id='+ ldata[i].id+'&uid='+ldata[i].user_id+'">');
                htmlText.push('<div class="weui-cell__hd ">');
                htmlText.push('<img class="head_top remainin" src="/storage/user_4/info/yax3Pahbz510vZCRFFBZDHWf0fmzPZy4jWiz4DkQ.png" alt="">');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__bd  weui-media-box__bd charname">');
                htmlText.push('<ul class="weui-media-box__info">');
                htmlText.push('<li class="weui-media-box__info__meta f20">');

                htmlText.push(ldata[i].sign);
                htmlText.push('</li>');
                //htmlText.push('<li class="weui-media-box__info__meta">啥耶');
                //htmlText.push('</li>');
                htmlText.push('</ul>');
                htmlText.push('<h4 class="weui-media-box__title gary9 f30">');
                htmlText.push(ldata[i].created_at);
                htmlText.push('</h4>');
                htmlText.push('</div>');
                htmlText.push('<label class="weui-cell__hd f30">');
                if(ldata[i].type ===0){
                    htmlText.push("-"+ ldata[i].work_capital);
                  } else if(ldata[i].type ===1){
                    htmlText.push("+"+ ldata[i].work_capital);
                }

                htmlText.push('</label>');
                htmlText.push('</a>');
                htmlText.push('</div>');
                htmlText.push('</div>');
                htmlText.push('</div>');
            }
        }
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    //明细详情
    'remation': function(data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;
            htmlText.push('<div class="site weui-cells_checkbox">');
            htmlText.push('<div class="weui-cell ">');
            htmlText.push('<div class="weui-cell__hd">');
            if(ldata.type === 0){
                htmlText.push('<label for="name">出账金额:');
                htmlText.push('</label>');
            }else if(ldata.type === 1){
                htmlText.push('<label for="name">入账金额:');
                htmlText.push('</label>');
            }

            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__bd">');
            htmlText.push('<label for="name" class="gary9">');
            htmlText.push(ldata.work_capital);
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__dd gary9">');
            htmlText.push('<label for="name">元');
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('<div class="site weui-cells_checkbox">');
            htmlText.push('<div class="weui-cell ">');
            htmlText.push('<div class="weui-cell__hd fu20">');
            htmlText.push('<label for="name">类型:');
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__bd gary9">');
            if(ldata.type === 0){
                htmlText.push('<label for="name">支出');
                htmlText.push('</label>');
            }else if(ldata.type === 1){
                htmlText.push('<label for="name">入账');
                htmlText.push('</label>');
            }

            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('<div class="site weui-cells_checkbox">');
            htmlText.push('<div class="weui-cell ">');
            htmlText.push('<div class="weui-cell__hd fu20">');
            htmlText.push('<label for="name">时间:');
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__bd">');
            htmlText.push('<label for="name" class="gary9">');
            htmlText.push(ldata.updated_at);
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('<div class="site weui-cells_checkbox">');
            htmlText.push('<div class="weui-cell ">');
            htmlText.push('<div class="weui-cell__hd fu10">');
            htmlText.push('<label for="name">流水号:');
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__bd">');
            htmlText.push('<label for="name" class="gary9 f20">');
            htmlText.push(ldata.sign);
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('<div class="site weui-cells_checkbox">');
            htmlText.push('<div class="weui-cell ">');
            htmlText.push('<div class="weui-cell__hd fu20">');
            htmlText.push('<label for="name">备注:');
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__bd">');
            htmlText.push('<label for="name" class="gary9">hello!');
            htmlText.push('</label>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('</div>');
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },

    // 外卖页面类型列表
    'takeoutTypeList': function (data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        var limit = 8,
            pageNum =  Math.ceil(len/8);
        console.log('pageNum', pageNum);

        if (len > 0) {
            // 页数
            for (var j = 1; j <= pageNum; j++) {
                var maxLen = j*limit-1,
                    minLen = j*limit-limit;
                htmlText.push('<div class="swiper-slide">');
                htmlText.push('<div class="weui-flex">');
                for (var i = minLen; i < len; i++) {
                    if (maxLen < i) {
                        break;
                    } else {
                        htmlText.push('<div class="weui-flex__item text-center" data-id="'+ ldata[i].id + '">');
                        htmlText.push('<div class="round reg-bg">');
                        htmlText.push('<img src="'+ ldata[i].picture + '" alt="">');
                        htmlText.push('</div>');
                        htmlText.push('<p class="sub-title nowrap">');
                        htmlText.push(ldata[i].catname);
                        htmlText.push('</p>');
                        htmlText.push('</div>');
                    }
                }
                htmlText.push('</div>');
                htmlText.push('</div>');
            }

        }
        console.log("123", htmlText.join(''));
        $(A.root).html(htmlText.join(''));
    },
    // 菜品类型列表
    'foodTypeList': function (data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        for (var i = 0; i < len; i++) {
            htmlText.push('<div class="weui-cell">');
            htmlText.push('<div class="weui-cell__bd">');
            htmlText.push('<p>');
            htmlText.push(ldata[i].menu_name);
            htmlText.push('</p>');
            htmlText.push('</div>');
            htmlText.push('<div class="weui-cell__ft">');
            htmlText.push('<span class="f30 mr-10 edit" data-id="'+ ldata[i].id +'">编辑</span>');
            htmlText.push('<span class="f30 del" data-id="'+ ldata[i].id +'">删除</span>');
            htmlText.push('</div>');
            htmlText.push('</div>');
        }

        console.log("123", htmlText.join(''));
        $(A.root).html(htmlText.join(''));
    },
    // 需要打印的菜品列表
    'selectFoodTypeList': function (data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;


        for (var i = 0; i < len; i++) {
            htmlText.push('<label for="x'+ i +'" class="weui-agree">');
            if (data.dData && data.dData.length > 0) {
                var dData = data.dData,
                    arr = dData.split(',');
                console.log("arr", arr);
                for (var j = 0, alen = arr.length -1; j < alen; j++) {
                    if (ldata[i].id == arr[j]) {
                        htmlText.push('<input id="x'+ i +'" checked type="checkbox" value="'+ ldata[i].id + '" class="weui-agree__checkbox">');
                    }
                }
            }

            htmlText.push('<input id="x'+ i +'" type="checkbox" value="'+ ldata[i].id + '" class="weui-agree__checkbox">');

            htmlText.push('<span class="weui-agree__text">');
            htmlText.push(ldata[i].menu_name);
            htmlText.push('</span>');
            htmlText.push('</label>');
        }

        console.log("123", htmlText.join(''));
        $(A.root).html(htmlText.join(''));
    },
    // 菜品详情页面
    'foodPanel': function (data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        htmlText.push('<div class="shops-detail-info white-bg">');
        htmlText.push('<div class="content-padded padding">');
        htmlText.push('<h2 class="f36 gary3 nowrap">');
        htmlText.push(ldata.dish.dishes_name);
        htmlText.push('</h2>');
        htmlText.push('<p class="summary f30 gary6 nowrap">招牌秘制烧汁+厚厚的烧鸡排+营养时蔬+精选米饭</p>');
        htmlText.push('<p class="f28 gary6 nowrap">');
        htmlText.push('月售' + ldata.dish.sales + '单');
        htmlText.push('</p>');
        htmlText.push('<p class="f28 gary6 nowrap">');
        if (ldata.discount < 1) {
            htmlText.push('<del class="f32 gary9">');
            htmlText.push(ldata.dish.price);
            htmlText.push('</del>');
            htmlText.push('<span class="f38 orange">');
            htmlText.push('￥' +  ldata.discount_price);
            htmlText.push('</span>');
        } else {
            htmlText.push('<span class="f38 orange">');
            htmlText.push('￥' + ldata.dish.price);
            htmlText.push('</span>');
        }


        htmlText.push('</p>');
        htmlText.push('<div class="btn">');
        if (ldata.dish.attribute) {
            htmlText.push('<a href="javascript:;" data-spend='+ ldata.shop.spend +' data-name='+ ldata.shop.shop_name +' data-text=\'' + JSON.stringify(ldata.dish) + '\' class="weui-btn weui-btn_mini weui-btn_primary more-select checkbtn">加入购物车</a>');
        } else {
            htmlText.push('<a href="javascript:;" data-spend='+ ldata.shop.spend +' data-name='+ ldata.shop.shop_name +' data-text=\'' + JSON.stringify(ldata.dish) + '\' class="weui-btn weui-btn_mini weui-btn_primary add checkbtn">加入购物车</a>');

        }
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');

        htmlText.push('<a href="/mobile/shops/'+ ldata.shop.id +'">');
        htmlText.push('<div class="shops-info padding row white-bg">');
        htmlText.push('<div class="arrow-right">');
        htmlText.push('<div class="col-2">');
        if (ldata.shop.shop_pic) {
            htmlText.push('<img src="'+ ldata.shop.shop_pic +'" alt="" class="img-responsive">');
        } else {
            htmlText.push('<img src="/img/eat.png" alt="" class="img-responsive">');
        }

        htmlText.push('</div>');
        htmlText.push('<div class="col-10">');
        htmlText.push('<div class="text">');
        htmlText.push('<h3 class="f32 gary3 nowrap">');
        htmlText.push(ldata.shop.shop_name);
        htmlText.push('</h3>');
        htmlText.push('<p class="f28 gary9 nowrap">');
        htmlText.push(ldata.shop.note);
        htmlText.push('</p>');
        htmlText.push(' </div>');
        htmlText.push(' </div>');
        htmlText.push(' </div>');
        htmlText.push(' </div>');
        htmlText.push(' </a>');


        console.log("123", htmlText.join(''));
        $(A.root).html(htmlText.join(''));
    },
    // 菜的评论
    'foodComments': function (data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;


        for (var i = 0; i < len; i++) {
            htmlText.push('<li>');
            htmlText.push('<div class="row padding">');
            htmlText.push('<div class="col-2">');
            if (ldata[i].users.avatar) {
                htmlText.push('<img src="' + ldata[i].users.avatar + '" alt="" class="img-responsive">');
            } else {
                htmlText.push('<img src="/img/eat.png" alt="" class="img-responsive">');
            }
            htmlText.push('</div>');
            htmlText.push('<div class="col-10">');
            htmlText.push('<div class="text">');
            htmlText.push('<h4 class="f30 gary9">');
            htmlText.push(ldata[i].users.name);
            htmlText.push('<span class="pull-right f26 gary9">');
            htmlText.push(ldata[i].created_at);
            htmlText.push('</span>');
            htmlText.push('</h4>');
            htmlText.push('<p class="f28 content">');
            htmlText.push(ldata[i].content);
            htmlText.push('</p>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('</div>');
            htmlText.push('</li>');

        }

        console.log("123", htmlText.join(''));
        $(A.root).html(htmlText.join(''));
    },
    // 首页商圈下拉菜单
    'shopsRoundList': function (data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;
        A.root = data.element;

        console.log("len", len);
        if (len > 0) {
            for (var i = 0; i < len; i++) {
                htmlText.push('<label class="weui-cell weui-check__label" for="x12">');
                htmlText.push('<div class="weui-cell__bd">');
                htmlText.push('<p class="text-left">');
                htmlText.push(ldata[i].name);
                htmlText.push('</p>');
                htmlText.push('</div>');
                htmlText.push('<div class="weui-cell__ft">');
                htmlText.push('<input type="radio" data-text="商圈" name="radio1" value="" class="weui-check" id="x12">');
                htmlText.push('<span class="weui-icon-checked"></span>');
                htmlText.push('</div>');
                htmlText.push('</label>');
            }
        }
        console.log("123", htmlText.join(''));
        $(A.root).append(htmlText.join(''));
    },
    // 桌子详情
    'roomDetail': function (data) {
        var ldata = data.data,
            htmlText = [];
        A.root = data.element;

        htmlText.push('<div class="weui-form-preview" style="min-height: 100%;">');
        htmlText.push('<div class="weui-form-preview__hd">');
        htmlText.push('<label class="weui-form-preview__label">名称</label>');
        htmlText.push('<em class="weui-form-preview__value">');
        htmlText.push(ldata.name);
        htmlText.push('</em>');
        htmlText.push('</div>');
        htmlText.push('<div class="weui-form-preview__bd">');
        htmlText.push('<div class="weui-form-preview__item">');
        htmlText.push('<label class="weui-form-preview__label">类型</label>');
        if (ldata.type == 0) {
            htmlText.push('<span class="weui-form-preview__value">桌子</span>');
        } else {
            htmlText.push('<span class="weui-form-preview__value">包间</span>');
        }

        htmlText.push('</div>');
        htmlText.push('<div class="weui-form-preview__item">');
        htmlText.push('<label class="weui-form-preview__label">容纳人数</label>');
        htmlText.push('<span class="weui-form-preview__value">');
        htmlText.push(ldata.hold + ' 人');
        htmlText.push('</span>');
        htmlText.push('</div>');
        htmlText.push('<div class="weui-form-preview__item">');
        htmlText.push('<label class="weui-form-preview__label">最低消费</label>');
        htmlText.push('<span class="weui-form-preview__value">');
        htmlText.push(ldata.min_consumption + ' 元');
        htmlText.push('</span>');
        htmlText.push('</div>');
        htmlText.push('<div class="weui-form-preview__item">');
        htmlText.push('<label class="weui-form-preview__label">状态</label>');
        if (ldata.is_use == 0) {
            htmlText.push('<span class="weui-form-preview__value">未使用</span>');
        } else {
            htmlText.push('<span class="weui-form-preview__value">使用中</span>');
        }

        htmlText.push('</div>');
        htmlText.push('<div class="weui-form-preview__item">');
        htmlText.push('<label class="weui-form-preview__label">说明</label>');
        htmlText.push('<span class="weui-form-preview__value">');
        htmlText.push(ldata.note);
        htmlText.push('</span>');
        htmlText.push('</div>');
        htmlText.push('</div>');
        htmlText.push('</div>');

        $(A.root).append(htmlText.join(''));
    },
    'talbeCodeList': function (data) {
        var ldata = data.data,
            htmlText = [],
            len = ldata.length;

        A.root = data.element;

        for (var i = 0; i < len; i++ ) {
            htmlText.push('<a href="javascript:;" class="weui-grid js_grid gary3" id="'+ ldata[i].id +'">');
            htmlText.push('<p class="title text-center">');
            htmlText.push(ldata[i].name);
            htmlText.push('</p>');
            htmlText.push(' </a>');
        }

        console.log("htmlText", htmlText);
        $(A.root).append(htmlText.join(''));
    }


};
// 创建视图入口
A.init = function (data) {
    this.strategy[data.type](data);
};

// 模板渲染方法
A.formateString = function (str, data) {
    console.log("data", data);
    return str.replace(/\{#(\w+)#\}/g, function (match, key) {
        return typeof data[key] === 'undefined' ? '' : data[key];
    })
};

// 模板生成器
A.view = function (name) {
  var v = {
    // 代码模板
      code: '<pre><code>{#code#}</code></pre>',
    // 图片模板
      img: '<img src="{#img#}" alt="{#alt#}" title="{#title#}"/>',
    // 带有 id 和类的模板
      part: '<div id="{#id#}" class="{#class#}">{#part#}</div>',
    // 组合模板
      theme: [
          '<div>',
            '<h1>{#title#}</h1>',
            '{#content#}',
          '</div>'
      ].join('')
  };

    // 如果参数是一个数组, 则返回多行模板
    if (Object.prototype.toString.call(name) === "[object Array]") {
        // 模板缓存器
        var tpl = '';
        // 遍历标识
        for (var i = 0, len = name.length; i < len; i++) {
            tpl += arguments.calle(name[i]);
        }
        // 返回最终模板
        return tpl;
    } else {
        // 如果模板库中有该模板则返回该模板,否则返回简易模板
        return v[name] ? v[name] : ('<' + name + '>{#' + name + '#}</' + name + '>');
    }
};

/*
* 观察者模式,订阅事件
*
* */
var Observer = (function () {
    // 防止消息附表暴漏而被篡改,故将消息容器作为静态私有变量保存
    var __message = {};

    return {
        // 注册事件
        regist: function (type, fn) {
            console.log("type", type);
            // 如果此消息不存在则应该创建一个该消息类型
            if (typeof __message[type] === 'undefined') {
                // 将动作推入该消息对应的动作执行队列中
                __message[type] = [fn];
            } else {
                // 将动作方法推入该消息对应的动作执行序列
                __message[type].push(fn);
            }
            console.log("__message", __message);
        },
        // 消息发布接口
        fire: function (type, args) {
            console.log("__message1", __message);
            // 如果该消息没有被注册,则返回
            if (!__message[type]) {
                return;
            }
            // 定义消息信息
            var events = {
                type: type,  // 消息类型
                args: args || []    // 消息携带数据
            },
            i = 0,  // 消息动作循环变量
            len = __message[type].length;   // 消息动作长度

            // 遍历消息动作队列
            for(; i < len; i++) {
                // 依次执行注册的消息对应动作
                __message[type][i].call(this, events);
            }

        },
        // 移除信息接口
        remove: function () {
            // 如果消息队列存在
            if (__message[type] instanceof Array) {
                // 从最一个消息动作遍历
                var i = __message[type].length - 1;

                for (; i > 0; i++) {
                    // 如果存在该动作则移除相应动作
                    __message[type][i] === 'function' && __message[type].splice(i,1);
                }
            }
        }
    }
})();

/*
 * 本地存储类
 * @preId : 本地存储库前缀
 * @timeSign : 时间戳与存储数据之间的拼接符
 * */
var BaseLocalStorage = function (preId, timeSign) {
    // 定义本地存储库前缀
    this.preId = preId;
    // 定义时间戳与数据之间的拼接符
    this.timeSign = timeSign || '|-|';
};
// 本地存储库原型方法
BaseLocalStorage.prototype = {
    // 操作状态
    status: {
        success: 1, //成功
        failure: 0, //失败
        overflow: 2, // 溢出
        timeout: 3  // 过期
    },
    // 保存本地存储库链接
    storage: localStorage || window.localStorage,
    // 获取本地存储数据库真实字段
    getKey: function (key) {
        return this.preId + key;
    },
    /*
     * 添加(修改)数据
     * @key : 数据字段标识
     * @value : 数据值
     * @callback : 回调函数
     * @time : 添加时间
     * */
    set: function (key, value, callback,time) {
        //console.log(typeof value);
        // 默认操作成功
        var status = this.status.success,
            // 获取真实字段
            key = this.getKey(key);
        // 如果传过来的不最字符串
        if ( typeof value !== 'string') {
            value = JSON.stringify(value);
        }
        try {
            // 获取参数时间的时间戳
            time = new Date(time).getTime() || time.getTime();
        } catch (e) {
            // 为传入时间参数,或者时间参数有误时,获得默认时间周期: 1月
            time = new Date().getTime() + 1000 * 60 * 60 * 24 * 31;
        }
        try {
            // 向数据库中添加数据
            this.storage.setItem(key, time + this.timeSign + value);
        } catch (e) {
            // 溢出失败
            status = this.status.overflow;
        }
        // 有回调函数,执行并传入参数操作状态,真实数据标识及存储数据值
        callback && callback.call(this, status, key, value);
    },
    /*
     * 获取数据
     * @key : 数据字段标识
     * @callback : 回调函数
     * */
    get: function (key, callback) {
        // 默认操作成功
        var status = this.status.success,
            //获取真实字段标识
            key = this.getKey(key),
            // 默认值为空
            value = null,
            // 时间戳与数据之间的拼接长度
            timeSignLen = this.timeSign.length,
            // 缓存当前对象
            _that = this,
            // 时间戳与字符拼接起始位置
            index,
            // 时间戳
            time,
            // 最终取得的数据
            result;
        try {
            // 获取字段对应的数据字符串
            value = _that.storage.getItem(key);
        } catch(e) {
            // 获取失败返回失败状态,数据为null
            result = {
                status: _that.status.failure,
                value: null
            };
            // 执行回调并返回
            callback && callback.call(this, result.status, result.value);
            return result;
        }
        // 如果成功获取数据
        if (value) {
            // 获取时间戳与数据之间的拼接符起始位置
            index = value.indexOf(_that.timeSign);
            // 获取时间戳
            time = +value.slice(0, index);
            // 如果没过期
            if (new Date(time).getTime() > new Date().getTime() || time == 0) {
                // 获取数据结果
                value = value.slice(index + timeSignLen);
            } else {
                // 过期则为 null
                value = null;
                // 设置状态为过期
                status = _that.status.timeout;
                // 删除字段
                _that.remove(key);
            }
        } else {
            // 没拿到数据
            status = _that.status.failure;
        }
        // 设置结果
        result = {
            status: status,
            value: value
        };
        // 执行回调
        callback && callback.call(this, result.status, result.value);
        // 返回结果
        return result;
    },
    /*
     * 删除数据
     * @key : 数据字段标识
     * @callback : 回调函数
     * */
    remove: function (key, callback) {
        // 设置状态默认失败
        var status = this.status.failure,
            // 获取真实字段标识
            key = this.getKey(key),
            // 设置数据结果为空
            value = null;
        try {
            // 获取字段对应数据
            value = this.storage.getItem(key);
        } catch(e) {}
        // 如果数据存在
        if (value) {
            try {
                // 删除数据
                this.storage.removeItem(key);
                // 设置操作状态为成功
                status = this.status.success;
            } catch(e) {}
        }
        // 执行回调函数
        callback && callback.call(this, status, status === 1 ? value.slice(value.indexOf(this.timeSign) + this.timeSign.length) : null)
    },
    // 获取数据存储的大小
    getSize: function () {
        var storage = this.storage,
            len = storage.length,
            str = "", // 所有数据字符串
            charCode, // 字符在编码中的位置
            total = 0; // 字节数
        // 遍历所有的 storage
        for (var i = 0; i < len; i++) {
            var key = storage.key(i);
            // 只要当前库的 数据,过滤掉缓存的用户信息
            if (!key.indexOf(this.preId) && key.indexOf(this.preId+"userInfo")) {
                // 拿到所有数据字符串
                str += storage.getItem(key);
            }
        }
        console.log("str", str);
        // 计算字节
        for (var i = 0, len = str.length; i < len; i++) {
            // 查找字符编码位置
            charCode = str.charCodeAt(i);
            // 确定是几个字节编码一个字符
            if (charCode <= 0xffff) {
                total += 2;
            } else {
                total += 4;
            }
        }
        // 因为 lostorage 最多只能存几M, 所以单位只算到 MB
        var KB = 1024,
            MB  = 1024 * 1024;
        console.log("字节数", total);
        // 数据大于 1 MB
        if (total / MB > 1) {
            return (total/MB).toFixed(2) + "M";
        } else if (total / KB > 1) {
            return (total / KB).toFixed(2) + "K";
        } else {
            return (total).toFixed(2) + "B"
        }
    },
    // 删除本库所有字段
    removeAllItem: function () {
        var storage = this.storage,
            len = storage.length;
        // 遍历所有的 storage
        for (var i = 0; i < len-1; i++) {
            var key = storage.key(i);
            // 只要当前库的 数据
            if (!key.indexOf(this.preId)) {
                // 删除有数据字符串
                storage.removeItem(key);
            }
        }
        console.log("删除成功");
        return "删除成功";
    }
};
window.Storage  = new BaseLocalStorage('ZLT_');

//获取url '？' 后面的参数
function getRequest () {
    var myRequest = {};
    var url = window.location.search;

    if (url.indexOf('?') !== -1) {
        var myUrl = url.substr(1);
        var arr = myUrl.split('&');
        for (var i = 0; i < arr.length; i++) {
            var name = arr[i].split('=')[0];
            var value = arr[i].split('=')[1];
            myRequest[name] = value;
        }
    }

    return myRequest;
}
// 根据店铺ID拿购物车数据
function getShopsCarData (shopsId) {
    var shopsCarList = Storage.get("shopsCarList");

    // 如果有缓存
    if (shopsCarList.status) {
        // 因为存的是字符串，所以先JSON格式化
        shopsCarList = JSON.parse(shopsCarList.value);

        // 拿到当前店铺缓存的菜
        var shopsData = shopsCarList[shopsId];
    }

    return shopsData;
}
// 根据店铺ID，清空购物车
function removeShopsCarData(shopsId) {
    var shopsCarList = Storage.get("shopsCarList");

    // 如果有缓存，
    if (shopsCarList.status) {
        // 因为存的是字符串，所以先JSON格式化
        shopsCarList = JSON.parse(shopsCarList.value);

        // 当前店铺缓存的设为空
        shopsCarList[shopsId] = "";

        // 重新缓存数据
        Storage.set("shopsCarList", JSON.stringify(shopsCarList));
    }
}

// 缓存到购物车
function shopCar (data) {
    console.log("data", data)
    // 注册一个事件，监听用户点菜事件
    if (data === 'first') {
        // 注册购物车事件
        Observer.regist("addShops", shopCar);
        Observer.regist("addShops", showMyFoods);
    }

    // 如果有数据传过来
    if (data.args) {
        var shops = [], // 要缓存的数据
            shopsId = data.args.shopsId, // 店铺ID
            foodsId = data.args.data.id, // 菜ID
            foods = data.args.data, // foods 数据
            foodsNum = data.args.data.num, // 菜的数量
            type = data.args.type;

        console.log("foodsNum", foodsNum);

        // 拿到缓存的数据
        var carData = getShopsCarData(shopsId);

        // 如果存在，要把购物车显示出来
        if (carData && carData.length > 0) {
            console.log("carData", carData);
            var index = '', // 默认没有这条菜
                fool = !1, // 多规格是否是一样的
                mIndex = ''; //多规格专用下标
            // 开始遍历菜数据
            for (var i = 0, len = carData.length; i < len; i++) {
                // 当前有缓存过这条菜，拿到当前菜的下标
                console.log("carData[i]", carData[i]);
                if (carData[i] && carData[i].id == foodsId) {

                    if (foodsNum == 0) {
                        carData.splice(i, 1);
                    } else {
                        // 如果添加的是多规格的
                        if (type === 'addMore' && carData[i].spec == foods.spec) {
                            fool = !0;
                            mIndex = i;
                        } else {
                            index = i;
                        }
                    }
                }
            }

            // 1、 有这条菜，单规格这个菜的数量会带过来，直接更新，
            // 2、 有这条菜，是多规格，规格一样，这个菜的数量也加1，
            // 3、 如果没有这条菜，或者这个菜是规格不一样的，直接加多一条，加的时候数量不能为0
            // 如果有这条菜，
            if (index !== '' || mIndex !== '') {
                // 更改这条菜的信息
                // 如果不是多规格
                if (type !== 'addMore') {
                    carData[index] = foods;
                } else {
                    // 是多规格，并且是一样的
                    console.log("是多规格，并且是一样的", foods);
                    if (fool) {
                        carData[mIndex] = foods;
                    } else {
                        // 如果是同一道菜，但菜的规格不一样，就直接加一条
                        carData.push(foods);
                    }
                }

            } else {
                if (foodsNum > 0) {
                    // 如果是新点的菜，直接加到后面
                    carData.push(foods);
                }
            }
            // 重新组织数据
            shops[shopsId] = carData;


        } else {
            // 用户还没有点过任何店铺的东西，直接加进去，缓存
            shops[shopsId] = [foods];
        }

        // 统一缓存到购物车
        Storage.set("shopsCarList", JSON.stringify(shops));

        console.log("shopsID我是", shopsId);
        // 显示购物车数量
        showCarBadge(shopsId);


    }

}

// 显示购物车数量图标
function showCarBadge (shopsId) {
    console.log("进来图标", shopsId);
    var carData = getShopsCarData(shopsId);
    if (carData && carData.length >= 0) {
        var num = carData.length;
        $(".car .weui-badge").text(num);

        // 计算总价
        getTotalPrice(shopsId);
    }
}
// 显示总价
function getTotalPrice(shopsId) {
    var data = getShopsCarData(shopsId),
        total = 0, // 总价
        price = 0, // 单价
        spcePrice = 0; // 多规格商品价格

    for (var i = 0, len = data.length; i < len; i++) {
        // 对多规格菜进行拆分，
        if (data[i].spec) {
            spcePrice = getMoreFoodPrice(data[i].spec);
        } else {
            // 如果不是多规格，直接设为0
            spcePrice = 0;
        }

        // 商品价格 = 折扣 * 商品数量 * 单价 + 多规格价 || 0
        price = parseFloat(data[i].discount) * parseInt(data[i].num) * (parseFloat(data[i].price) + spcePrice);

        // 原总价
        total += price;


    }
    total = total.toFixed(2);
    // 显示总价
    $(".total").text(total);
    return total;
}
// 拆分计算多规格菜价
function getMoreFoodPrice(spec) {
    var arr = spec.split(','),
        price = 0;

    for (var i = 0, len = arr.length; i < len; i++) {
        var arr1 = arr[i].split('|');
        if (arr1[1]) {
            price += parseFloat(arr1[1]);
        }

    }
    console.log("price", price);
    return price;

}
// 创建我已经点了的菜列表
function showMyFoods (data) {
    // 根据店铺ID拿到缓存的数据
    console.log("data", data);
    var shopsId = data.shopsId || data.args.shopsId;


    var carData = getShopsCarData(shopsId);
    if (carData && carData.length > 0) {
        var data = {};
        // 选择html模板
        data['type'] = 'myfoods';
        // 数据
        data['data'] = carData;
        // 当前页面承载模板的容器
        data['element'] = '#myFoodsList';

        // 渲染模板
        A.init(data);

    } else {
      $("#myFoodsList").html('');
        $.closePopup()
    }
}

// 显示多规格弹框
function showMore (text, data) {
    $.modal({
        title: "菜品名称",
        text: text,
        buttons: [
            { text: "取消", className: "default", onClick: function(){ console.log(3)} },
            { text: "加入购物车", onClick: function(){

                // 拿到菜的信息
                var food = data;
                // 获取多规格数量
                var number = getMoreFoodNum(food.shop_id, food.id);
                if (number && number > 0) {
                    food['num'] = number + 1;
                } else {
                    food['num'] = 1;
                }


                // 拿到店铺ID
                var shopsId = food.shop_id;
                // 尝试拿已经点菜的规格
                var spec = food.spec || "";

                if (!spec) {
                    var len = $(".taste.active").length;
                    console.log("len", len);
                    // 如果没有，就按用户点的来
                    $(".taste.active").each(function (index,value) {
                        console.log("index", index);
                        console.log("value", value);
                        // 拿到所有选中的多规格
                        if (index === len -1) {
                            spec += $(this).text()
                        } else {
                            spec += $(this).text()  + ',';
                        }

                    });
                }

                // 拿到用户选的多规格
                food['spec'] = spec;
                console.log("food", food);
                // 点击加菜，要把事件和数据发布出去，给购物车做显示
                Observer.fire("addShops", {
                    shopsId: shopsId,
                    type: 'addMore',
                    data: food
                });
            }}
        ]
    });
}
//  获取缓存的菜的num
function getMoreFoodNum (sid, id) {
    var carData = getShopsCarData(sid),
        number = 0;
    if (carData && carData.length > 0) {
        for (var i = 0; i < carData.length; i++) {
            if (id == carData[i].id) {
                number = carData[i].num;
            }
        }
    }

    return number;
}
// 创建多规格HTML
function createMorePane (data) {
        var ldata = data,
            htmlText = [];

        htmlText.push('<div class="more-food">');
        for (var i = 0, len = ldata.length; i < len; i++ ) {
            htmlText.push('<div class="more-item">');
            htmlText.push('<div class="more-title text-left">');
            htmlText.push(ldata[i].attribute);
            htmlText.push('</div>');
            htmlText.push('<div class="more-content weui-flex">');
            for (var j = 0, jlen = ldata[i].spec.length; j < jlen; j++) {
                if (j < 1) {
                    htmlText.push('<span class="taste active"  data-price="'+ ldata[i].spec[j].spec_price +'">');
                    htmlText.push(ldata[i].spec[j].spec_name);
                    htmlText.push("|");
                    htmlText.push(ldata[i].spec[j].spec_price);
                    htmlText.push('</span>');
                    //购物车规格价要显示
                } else {
                    htmlText.push('<span class="taste" data-price="'+ ldata[i].spec[j].spec_price +'">');
                    htmlText.push(ldata[i].spec[j].spec_name);
                    htmlText.push("|");
                    htmlText.push(ldata[i].spec[j].spec_price);
                    htmlText.push('</span>');
                    //购物车规格价要显示
                }
            }
            htmlText.push('</div>');
            htmlText.push('</div>');
        }
        htmlText.push('</div>');
        console.log("htmlText",  htmlText.join(''));
        return htmlText.join('');

}
//  获取userInfo用户信息
function getUserInfo (_token, callback) {
    $.post("/api/user/userMessage", {_token: _token}, function (res) {
        //console.log("res", res);
        res = JSON.parse(res);
        userInfo = res.data;
        // 缓存
        Storage.set("userInfo", JSON.stringify(res.data));
        typeof callback === 'function' && callback(res.data);
    });
}

// 获取用户选择地址信息
function getMyAddress (_token) {
    var address = Storage.get("address");

    if (address.status) {
        address = JSON.parse(address.value);
        console.log("address");
    }

    return address;
}


// 上传图片
function saveImg (url, formId, callback, element) {

    // var file = $("#uploaderInput").prop('files')[0],
    //     r = new FileReader();
    //
    //     console.log("file", file),
    //     r.readAsDataURL(file);
    //     r.onload = function (evt) {
    //         // 拿到图片的base64
    //         var urlBase64 = evt.target.result;
    //         console.log("file", evt.target.result);
    //
    //         // 图片预览
    //         $(".weui-gallery .weui-gallery__img").css("background-image", 'url(' +urlBase64 +')');
    //         $(".weui-gallery").show();
    //         // $(".head_s").attr("src", urlBase64);
    //     };


        // 提交数据
    var form = $(formId)[0];
    var formData = new FormData(form);

    $.ajax({
        type: "POST",
        data: formData,
        url: url,
        processData: false,
        contentType: false,
        success: function (res) {
            if (typeof res === 'string') {
                res = JSON.parse(res);
            }
            typeof callback === 'function' && callback(res, element);
        },
        error: function (err) {
            console.log("err", err);
        }
    });



}

// 长按事件
var timeStart,timeEnd,time;

// 获取当前时间
function getTimeNow () {
    var now = new Date();
    return now.getTime();
}

// 鼠标按下
function holdDown (callback) {
    // 拿到按下的时间戳
    timeStart = getTimeNow();

    time = setInterval(function () {
        // 每隔100 再拿一次时间戳
        timeEnd = getTimeNow();
        // 两次时间戳对比,超过 500 为长按
        if (timeEnd - timeStart >= 500) {
            clearInterval(time);
            console.log("长按了");
            typeof callback === 'function' && callback();
        }
    },100);
}

// 清除
function holdUp () {
    clearInterval(time);
}

// 判断是不是在微信浏览器
function isWechatBrowser () {
    return navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1;
}

/*
*
* 分页
*
*
* */
var AjaxPage = function (setting) {
    // 缓存数据
    var cache = [];

    var _that = this;
    // 获取基本配置
    this.setting = this.getSetting();

    // 合并配置
    this.setting = $.extend(this.setting, setting);

    // 获取数据
    this.getData(this.setting);

    // 滚动容器
    this.cElement = $(this.setting.cElement);
    console.log(" this.cElement",  this.cElement);

    // 监听下拉刷新
    $(this.cElement).infinite(200).on("infinite", function() {

        console.log("_that.setting.loading", _that.setting.loading);
        // 如果正在加载，返回
        if(_that.setting.loading) return;

        // 页数 +1
        _that.setting.arg.page++;

        // 请求数据
        _that.getData(_that.setting);

    });

};
AjaxPage.prototype = {

    // 获取数据
    getData: function (setting) {
        var _that = this;
        setting.loading = !0;
        // 发出请求
        $.ajax({
            url: setting.url,
            data: setting.arg,
            type: setting.ajaxType,
            success: function (res) {
                if (typeof res === 'string') {
                    res = JSON.parse(res);
                }
                //获得 总记录条数
                var total = res.data.total || 0;

                if (res.code == 200) {
                    // 有数据
                    var data = {};
                    // 创建数据的模板类型
                    data['type'] = setting.type;

                    // 列表存放的容器
                    data['element'] = setting.element;

                    // 数据
                    data['data'] = res.data.data || res.data;

                    // 开始创建
                    A.init(data);

                    // 缓存数据
                    console.log("res.data.length", res.data.length);
                    // 如果当前已经是最后一页
                    if (res.data.length < 1 || setting.arg.num > res.data.length || setting.arg.limit > res.data.length || setting.arg.limit > total) {
                        // 设置加载状态为true,数据加载完成
                        console.log("进来了@");
                        setting.loading = !0;
                        console.log("_that.setting.loading", setting.loading);
                        // 不在请求
                        _that.setStatus();

                    } else {
                        // 有数据,下拉还有请求
                        setting.loading = !1;
                    }
                } else {
                    // 设置加载状态为true,数据加载完成
                    setting.loading = !0;

                    _that.setStatus();
                    console.log("_that.setting.element", setting.element);
                }

            },
            error: function (err) {
                console.log("err is ", err);
            }
        });
    },
    // 获取基本配置
    getSetting: function () {
        return {
            url: '',    //路径
            cElement: '',    // 滚动容器
            element: '',    // 列表容器
            total: 0,   // 总记录条数
            loading: !1, // 加载状态
            ajaxType: 'POST',
            arg: {      // 请求参数
                page: 1,
                limit: 6
            }
        };
    },
    // 显示列表状态,正在加载,或者加载完成
    setStatus: function () {
        $(document.body).destroyInfinite();
        // 更改提示状态
        $(".hasdata").hide(function () {
            $(".nodata").show();
        });
    }
};
AjaxPage.init = function (setting) {
    new this(setting);
};
window['AjaxPage'] = AjaxPage;

/*
 *
 * 节流器
 * */
var throttle = function () {
    // 获取第一个参数
    var isClear = arguments[0], fn, param;
    //如果第一个参数是boolean类型，那么第一个参数则表示是否清除计时器
    if (typeof isClear === 'boolean') {
        // 第二个参数为函数
        fn = arguments[1];

        // 函数的计时器句柄存在，则清除该计时器
        fn._throttleID && clearTimeout(fn.__throttleID);
    } else {
        //通过计时器延迟执行函数
        fn = isClear; // 第一个参数为函数
        // 第二个参数为函数执行时的参数
        param = arguments[1];
        // 对执行时的参数适配默认值
        var p = $.extend({
            context: null, //执行函数时的作用域
            args: [],   // 参数
            time: 300, // 延时执行的时间
        }, param);
        // 清除执行函数计时器句柄
        arguments.callee(true, fn);
        // 为函数绑定计时器句柄
        fn.__throttleID = setTimeout(function (){
            fn.apply(p.context, p.args);
        },p.time)
    }
};

// 获取地理位置
function getLocation (cb) {
    // 初始化定位接口
    var geo = new qq.maps.Geolocation("MFJBZ-WFGW6-7WDSW-ETQYY-FZP3S-MSFQ5", "myapp");
    console.log("geo", geo);
    geo.getLocation(function (r) {
        console.log("r", r);
        cityInfo = r;
        lat = r.lat;
        lng = r.lng;

        // 定位到城市
        $(".city").text(cityInfo.city);

        // 缓存城市信息
        Storage.set("cityInfo", JSON.stringify(cityInfo));
        typeof cb === 'function' && cb (cityInfo);
    }, function (err) {
        console.log("err", err);
    });
}
// 格式化商圈列表数据
function getMyData(obj) {
    console.log("obj", obj);
    var data = [];
    for (var i = 0, len = obj.length; i < len; i++) {
        data.push({value: obj[i].id, name: obj[i].zonename});
    }
    return data;
}

// 米的单位换算
function getSistanceStr (num) {
    var str = "";
    if (num < 1000) {
        str = num + "m"
    } else {
        str = (num/1000).toFixed(2) + "km"
    }

    return str;
}
// 文档加载完成后
$(document).ready(function () {
    // tab切换
    $(".nav-tabs").on("click", "a", function () {
        // 拿到当前点击菜单的ID
        var id = $(this).attr("data-id");
        // 给当前菜单设置样式，其兄弟所有元素去掉 active
        $(this).addClass("active").parent("li").siblings().children("a").removeClass("active");
        // 当前id 对应的内容面板展示
        $(id).addClass("active").siblings().removeClass("active");
    });

    // 计数器,使用事件代理，简化绑定事件
    $("body").on("click", ".weui-count", function (e) {
            // 获得当前点击的元素
        var eid = e.target.id,
            // 获得当前元素下，input
            input = $(this).find("#num"),
            // 拿到点击减元素
            delBtn = $(this).find("#del"),
            // 获得input 框的值
            num = input.val();

            var food = $(this).attr("data-text");
                console.log("food", food);
                food = JSON.parse(food);

            var shopsId = food.shop_id,
                otherInput = $(".input" + food.id); // 列表上对应的input
            var type = 'add';
            if (food.attribute) {
                type = 'addMore'
            }
        switch(eid) {
            // 加
            case 'add':
                num++;
                input.val(num);
                otherInput.val(num);
                // 把那个减号和input 显示出来
                if (input.hasClass('hide')) {
                    input.removeClass('hide');
                    delBtn.removeClass('hide');
                }
                food['num'] = num;

                // 点击加菜，要把事件和数据发布出去，给购物车做显示
                Observer.fire("addShops", {
                    shopsId: shopsId,
                    type: type,
                    data: food
                });
                break;
            // 减
            case 'del':
                // num 不能小于0
                if (num > 0) {
                    // 菜的数量 -1
                    num--;
                    // input 显示对应的值
                    input.val(num);
                    otherInput.val(num);

                    // 设置当前点的菜的数量
                    food['num'] = num;

                    // 点击减菜，要把事件和数据发布出去，给购物车做显示
                    Observer.fire("addShops", {
                        shopsId: shopsId,
                        type: type,
                        data: food
                    });
                } else if (num == 0) {
                    input.addClass('hide');
                    delBtn.addClass('hide');
                }
                break;
            default:
        }
    });

    // 点击多规格按钮
    $(".tab-content").on("click", ".more-select", function () {
        // 拿到多规格数据
        var data =  $(this).attr("data-text");
            data = JSON.parse(data);

        var text = createMorePane(data.attribute);

        // 显示多规格面板
        showMore(text, data);
    });

    // 选取规格
    $("body").on("click", ".taste", function () {
        $(this).addClass("active").siblings().removeClass("active");
    });

    // 导航状态切换
    var pathname = window.location.pathname;
    //console.log("mylocal", pathname);
    var indexHtml = '<use xlink:href="#icon-home-active"></use>';
    var userHtml = '<use xlink:href="#icon-user-active"></use>';

    $(".footer-tabbar a").each(function () {
        var path = $(this).attr("href");
        if (!path.indexOf(pathname)) {
            console.log("path", path);
            $(this).addClass("weui-bar__item--on").siblings().removeClass("weui-bar__item--on");
            if (path === '/mobile/index') {
                $(this).find("svg").html(indexHtml);
            } else if (path === '/mobile/mine') {
                $(this).find("svg").html(userHtml);
            }

        }
    });

    // 评论点击事件

    $(".comment-stars svg").on('hover click', function () {
        $(this).addClass("orange").prevAll().addClass("orange")
        $(this).nextAll().removeClass("orange");
    });

});

